RxState
Simple way to connect rxjs to React component in Redux style... but without dispatch and constants.
Installation
npm install --save rx_state
Explanation
At the beginning I didn't plan to make it a library, it was only an idea described in Use RxJS with React. I've changed my mind after couple people pinged me about it. I recommand to read the article if you want to learn and understand rationale behind this approach.
Entire library source has 60 lines so you can start from the source code.
How to use it
Create actions
No magic here, action is just new Rx.Subject
. Forget about CONSTANTs.
; "increment$" "decrement$" "reset$";
Create reducer
As you can see our reducer is an observable of tiny functions which are going to modify state. RxState won't help you here, just RxJS.
;; const initialState = 0; const CounterReducer$ = RxObservable ; $;
That was the difficult part.
Create root reducer
This strange-looking map makes reducer scoped.
;; const reducer$ = RxObservable; $;
Create and provide state
;;; ReactDOM;
Connect your components
; counter: statecounter { counterActionsincrement$nextn; } { counterActionsdecrement$nextn; }Counter;
Read more about RxJS with React: http://michalzalecki.com/use-rxjs-with-react