You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And a helper function connectAction to stream actions to store (see example below).
What does it look like?
import{createStore,combineReducers,applyMiddleware,connectAction}from'rx-redux'importthunkMiddlewarefrom'redux-thunk'import*asreducersfrom'./reducers'import{render,getActionStream}from'./view'constaction$=getActionStream();constnewCreateStore=applyMiddleware(thunkMiddleware)(createStore);constreducer=combineReducers(reducers);conststore=newCreateStore(reducer);// stream states to viewstore.state$.subscribe(state=>render(state));// stream actions to dispatcheraction$.subscribe(action=>store.dispatcher$.onNext(action));// or you can write this way// connectAction(action$, store);
Best practice to make your app all the way reactive
Don't do async in Middleware, create RxMiddleware instead.
importRxfrom'rx';exportdefaultfunctionthunkMiddleware(getState){returnaction=>{if(typeofaction==='function'){returnRx.Observable.just(action(getState));}// Don't know how to handle this thing, pass to next rx-middlewarereturnRx.Observable.just(action);};}