How to properly use an observable with Redux store and routing

Viewed 1238

Using the real-world example from Redux, where would one best define an observable and then listeners on the Redux store? For example from this Redux discussion thread, when utilizing redux-rx where should the following code be placed in the real-world example?

const state$ = observableFromStore(store);

const didLogin$ = state$
    .distinctUntilChanged(state => !state.loggedIn && state.router.path === '/login')
    .filter(state => state.loggedIn && state.router.path === '/login');

didLogin$.subscribe({
    router.transitionTo('/success');
});

I was initially thinking that I would define this within containers/App.js but at that level the redux store is not available like it is in index.js and containers/Root.dev.js. Perhaps utilizing React context somehow? I am using a reselect selector for my connect() calls if that makes any difference.

0 Answers
Related