diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-10-02 15:28:25 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-10-02 15:28:25 +0200 |
commit | cd2d5e5101edb466b13ada19b09ea42ef726ad96 (patch) | |
tree | 108b4aaf2c87f60a790e318ecaaa64eeecf59062 /packages/gitbook-core/src/lib/createContext.js | |
parent | 5abac3a79a01698d69c3273a3f1398b63012a4b8 (diff) | |
download | gitbook-cd2d5e5101edb466b13ada19b09ea42ef726ad96.zip gitbook-cd2d5e5101edb466b13ada19b09ea42ef726ad96.tar.gz gitbook-cd2d5e5101edb466b13ada19b09ea42ef726ad96.tar.bz2 |
Pass actions to thunk acitons
Diffstat (limited to 'packages/gitbook-core/src/lib/createContext.js')
-rw-r--r-- | packages/gitbook-core/src/lib/createContext.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/packages/gitbook-core/src/lib/createContext.js b/packages/gitbook-core/src/lib/createContext.js index d19e0f6..ec240be 100644 --- a/packages/gitbook-core/src/lib/createContext.js +++ b/packages/gitbook-core/src/lib/createContext.js @@ -11,6 +11,8 @@ const Components = require('../actions/components'); const I18n = require('../actions/i18n'); const Navigation = require('../actions/navigation'); +const isBrowser = (typeof window !== 'undefined'); + const corePlugin = new Plugin({ reduce: coreReducers, actions: { @@ -38,13 +40,19 @@ function createContext(plugins, initialState) { return Object.assign(accu, plugin.actions); }, {}); + // Create thunk middleware which include actions + const thunk = ReduxThunk.withExtraArgument(actions); + + // Create the redux store const store = Redux.createStore( (state, action) => { - console.log('[store]', action.type); + if (isBrowser) { + console.log('[store]', action.type); + } return reducer(state, action); }, initialState, - Redux.compose(Redux.applyMiddleware(ReduxThunk)) + Redux.compose(Redux.applyMiddleware(thunk)) ); // Initialize the plugins |