All Projects → Dynalon → Reactive State

Dynalon / Reactive State

Licence: mit
Redux-clone build with strict typing and RxJS down to its core. Wrist-friendly, no boilerplate or endless switch statements

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Reactive State

Fluorine
[UNMAINTAINED] Reactive state and side effect management for React using a single stream of actions
Stars: ✭ 287 (+112.59%)
Mutual labels:  rxjs, state-management
Platform
Reactive libraries for Angular
Stars: ✭ 7,020 (+5100%)
Mutual labels:  rxjs, state-management
Awesome Rxjs
A collection of awesome RxJS resources
Stars: ✭ 314 (+132.59%)
Mutual labels:  rxjs, functional-reactive-programming
Ayanami
🍭 A better way to react with state
Stars: ✭ 129 (-4.44%)
Mutual labels:  rxjs, state-management
Sigi
Well designed effect management framework for complex frontend app
Stars: ✭ 95 (-29.63%)
Mutual labels:  rxjs, state-management
Mobx Keystone
A MobX powered state management solution based on data trees with first class support for Typescript, support for snapshots, patches and much more
Stars: ✭ 284 (+110.37%)
Mutual labels:  functional-reactive-programming, state-management
Focal
Program user interfaces the FRP way.
Stars: ✭ 613 (+354.07%)
Mutual labels:  rxjs, state-management
juliette
Reactive State Management Powered by RxJS
Stars: ✭ 84 (-37.78%)
Mutual labels:  rxjs, state-management
Rxstate
Simple opinionated state management library based on RxJS
Stars: ✭ 46 (-65.93%)
Mutual labels:  rxjs, state-management
Mini Rx Store
Lightweight Redux Store based on RxJS
Stars: ✭ 32 (-76.3%)
Mutual labels:  rxjs, state-management
reactive-store
A store implementation for state management with RxJS
Stars: ✭ 29 (-78.52%)
Mutual labels:  rxjs, state-management
Bloc.js
A predictable state management library that helps implement the BLoC design pattern in JavaScript
Stars: ✭ 111 (-17.78%)
Mutual labels:  rxjs, state-management
ngx-model-hacker-news-example
Example repository with Hacker News implementation using Angular, Angular Material & ngx-model
Stars: ✭ 27 (-80%)
Mutual labels:  rxjs, state-management
Akita
🚀 State Management Tailored-Made for JS Applications
Stars: ✭ 3,338 (+2372.59%)
Mutual labels:  rxjs, state-management
rxdeep
rxjs deep state management
Stars: ✭ 47 (-65.19%)
Mutual labels:  rxjs, state-management
Mobius.swift
A functional reactive framework for managing state evolution and side-effects [Swift implementation]
Stars: ✭ 361 (+167.41%)
Mutual labels:  functional-reactive-programming, state-management
Airstream
State propagation and event streams with mandatory ownership and no glitches
Stars: ✭ 160 (+18.52%)
Mutual labels:  state-management, functional-reactive-programming
React-Redux-Enterprise
A React-Redux boilerplate for enterprise/large scaled web applications
Stars: ✭ 77 (-42.96%)
Mutual labels:  rxjs, react-redux
Mobius
A functional reactive framework for managing state evolution and side-effects.
Stars: ✭ 855 (+533.33%)
Mutual labels:  functional-reactive-programming, state-management
Store
Aurelia single state store based on RxJS
Stars: ✭ 103 (-23.7%)
Mutual labels:  rxjs, state-management

Build Status npm version code coverage

Reactive State

A typed, wrist-friendly state container aimed as an alternative to Redux when using RxJS. Written with RxJS in TypeScript but perfectly usable from plain JavaScript. Originally inspired by the blog posting from Michael Zalecki but heavily modified and extended since.

Features

  • type-safe actions: no boilerplate code, no mandatory string constants, and not a single switch statement
  • Actions are just Observables, so are Subjects. Just call .next() to dispatch an action.
  • dynamically add and remove reducers during runtime
  • no need for async middlewares such as redux-thunk/redux-saga; actions are Observables and can be composed and transformed async using RxJS operators
  • no need for selector libraries like MobX or Reselect, RxJS already ships it
  • single, application-wide Store concept as in Redux. Possibility to create slices/substates for decoupling (easier reducer composition and state separation by module)
  • Strictly typed to find errors during compile time
  • Heavily unit tested, 100+ tests for ~250 lines of code
  • React bridge (like react-redux) included, though using React is not mandatory
  • Support for React-Devtool Extension

Installation

npm install reactive-state

Documentation

Additionally, there is a small example.ts file and see also see the included unit tests as well.

Example Usage

import { Store } from "reactive-state";
import { Subject } from "rxjs";
import { take } from "rxjs/operators";

// The state for our example app
interface AppState {
    counter: number;
}

const initialState: AppState = { counter: 0 }

const store = Store.create(initialState);

// The .watch() function returns an Observable that emits the selected state change, so we can subscribe to it
store.watch().subscribe(newState => console.log("STATE:", JSON.stringify(newState)));

// the watch() observable always caches the last emitted state, so we will immediately print our inital state:
// [CONSOLE.LOG]: STATE: {"counter":0}

// use a RxJS Subjects as an action
const incrementAction = new Subject<number>();

// A reducer is a function that takes a state and an optional payload, and returns a new state
function incrementReducer(state, payload) {
    return { ...state, counter: state.counter + payload };
};

store.addReducer(incrementAction, incrementReducer);

// lets dispatch some actions

incrementAction.next(1);
// [CONSOLE.LOG]: STATE: {"counter":1}
incrementAction.next(1);
// [CONSOLE.LOG]: STATE: {"counter":2}

// async actions? No problem, no need for a "middleware", just use RxJS
interval(1000).pipe(take(3)).subscribe(() => incrementAction.next(1));
// <PAUSE 1sec>
// [CONSOLE.LOG]: STATE: {"counter":3}
// <PAUSE 1sec>
// [CONSOLE.LOG]: STATE: {"counter":4}
// <PAUSE 1sec>
// [CONSOLE.LOG]: STATE: {"counter":5}

License

MIT.

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].