All Projects → FE-Ractor → ractor

FE-Ractor / ractor

Licence: other
class action based state management inspired by Redux and Akka Actor

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to ractor

flutter modularization
[Flutter SDK V.2] - This repo will introduce you how to mastering your app with implementation Flutter Modularization in several ways
Stars: ✭ 78 (+20%)
Mutual labels:  state-management
xstate-cpp-generator
C++ State Machine generator for Xstate
Stars: ✭ 33 (-49.23%)
Mutual labels:  state-management
react-mui-pro-starter
Mix of Create React App and Material UI with set of reusable components and utilities to build professional React Applications faster.
Stars: ✭ 14 (-78.46%)
Mutual labels:  state-management
rxdeep
rxjs deep state management
Stars: ✭ 47 (-27.69%)
Mutual labels:  state-management
Vuex-Alt
An alternative approach to Vuex helpers for accessing state, getters and actions that doesn't rely on string constants.
Stars: ✭ 15 (-76.92%)
Mutual labels:  state-management
closeable-map
Application state management made simple: a Clojure map that implements java.io.Closeable.
Stars: ✭ 42 (-35.38%)
Mutual labels:  state-management
useStateMachine
The <1 kb state machine hook for React
Stars: ✭ 2,231 (+3332.31%)
Mutual labels:  state-management
vue-stores
Share the root states and methods in every component.
Stars: ✭ 16 (-75.38%)
Mutual labels:  state-management
flutter-bloc-patterns
A set of most common BLoC use cases built on top of flutter_bloc library
Stars: ✭ 58 (-10.77%)
Mutual labels:  state-management
react-wisteria
Managing the State with the Golden Path
Stars: ✭ 18 (-72.31%)
Mutual labels:  state-management
zustood
🐻‍❄️ A modular store factory using zustand
Stars: ✭ 46 (-29.23%)
Mutual labels:  state-management
ngx-model-hacker-news-example
Example repository with Hacker News implementation using Angular, Angular Material & ngx-model
Stars: ✭ 27 (-58.46%)
Mutual labels:  state-management
okwolo
light javascript framework to build web applications
Stars: ✭ 19 (-70.77%)
Mutual labels:  state-management
juliette
Reactive State Management Powered by RxJS
Stars: ✭ 84 (+29.23%)
Mutual labels:  state-management
reactive-store
A store implementation for state management with RxJS
Stars: ✭ 29 (-55.38%)
Mutual labels:  state-management
stoxy
Stoxy is a state management API for all modern Web Technologies
Stars: ✭ 73 (+12.31%)
Mutual labels:  state-management
dotto.x
A tiny state manager for React, Svelte, Vue and vanilla JS
Stars: ✭ 104 (+60%)
Mutual labels:  state-management
micro-observables
A simple Observable library that can be used for easy state management in React applications.
Stars: ✭ 78 (+20%)
Mutual labels:  state-management
react-smart-app
Preconfiguration React + Ant Design + State Management
Stars: ✭ 13 (-80%)
Mutual labels:  state-management
kladi
Easy to use state management library for React
Stars: ✭ 24 (-63.08%)
Mutual labels:  state-management

 

Ractor

Another action based state management tool

 

中文文档

Install

npm i ractor

Quick Start

Ractor builds upon three main ideas.

System

System is an event system. Normally, You need to create one for your logic app.

import { System } from "ractor";
export const system = new System("counter");

Action

The abstraction of system behavior. You can create it by class.

export class Increment {}

Store

Conceptually, your can think of Store like a event handler or redux’s reducer.

Store is an abstract class, abstract method createReceive needs to return an Receive object. There is a convenient helper method receiveBuilder to help you to create Receive object

import { Increment } from "./Increment";
import { Decrement } from "./Decrement";
import { Store } from "ractor";

export class CounterStore extends Store<{ value: number }> {
  public state = { value: 1 };
  public createReceive() {
    return this.receiveBuilder()
      .match(Increment, async () =>
        this.setState({ value: this.state.value + 1 }))
      .match(Decrement, async () =>
        this.setState({ value: this.state.value + 1 }))
      .build();
    }
}

There is a convenient function createStore to createStore quickly.

import { ReceiveBuilder } from "ractor"

const CounterStore = createStore((getState, setState) => {
  return ReceiveBuilder
    .create()
    .match(Increment, () => setState(getState() + 1))
    .match(Decrement, () => setState(getState() - 1))
    .build()
}, 0)

React

There is the quick glance of ractor-hooks

Provider

Create an event system for your App.

  import { Provider } from "ractor-hooks"
  import { System } from "ractor"

  function App() {
    return <Provider system={new System("app")}><Counter /></Provider>
  }

useStore

Inject Store to your component, return the state of the store which had injected.

function Counter() {
  const counter = useStore(CounterStore)
  return jsx
}

useSystem

Take the system out of current context.

function Counter() {
  const system = useSystem(CounterStore)
  return <button onClick={() => system.dispatch(new Increment)}>+</button>
}

Examples

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].