Skip to content

Commit

Permalink
Data Module: Support multiple stores for the redux dev tools
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Feb 9, 2018
1 parent 77dd2a8 commit 4be5974
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ export { loadAndPersist, withRehydratation } from './persist';
*/
const stores = {};
const selectors = {};
const enhancers = [];
let listeners = [];
if ( window.__REDUX_DEVTOOLS_EXTENSION__ ) {
enhancers.push( window.__REDUX_DEVTOOLS_EXTENSION__() );
}

/**
* Global listener called for each store's update.
Expand Down Expand Up @@ -52,6 +48,10 @@ export const subscribe = ( listener ) => {
* @return {Object} Store Object.
*/
export function registerReducer( reducerKey, reducer ) {
const enhancers = [];
if ( window.__REDUX_DEVTOOLS_EXTENSION__ ) {
enhancers.push( window.__REDUX_DEVTOOLS_EXTENSION__( { name: reducerKey, instanceId: reducerKey } ) );
}
const store = createStore( reducer, flowRight( enhancers ) );
stores[ reducerKey ] = store;
store.subscribe( globalListener );
Expand Down

0 comments on commit 4be5974

Please sign in to comment.