Closed zalmoxisus closed 7 years ago
As discussed in #4, it allows to separate the monitor app from watching actions and effects.
So, on the client side we use:
const monitor = createSagaMonitor({ dispatch: (action) => { window.postMessage(action, '*') } }) const sagaMiddleware = createSagaMiddleware({sagaMonitor: monitor}) const store = createStore( reducer, applyMiddleware(sagaMiddleware) ) sagaMiddleware.run(rootSaga)
Then on the other side we get actions right in the monitor's store:
const sagaStore = createStore(sagaReducer) function handleMessages(event) { sagaStore.dispatch(event.data) } window.addEventListener('message', handleMessages, false) ReactDOM.render( <SagaMonitor monitor={{store: sagaStore}} />, document.getElementById('root') );
thanks!
As discussed in #4, it allows to separate the monitor app from watching actions and effects.
So, on the client side we use:
Then on the other side we get actions right in the monitor's store: