diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-10-01 14:39:09 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-10-01 14:39:09 +0200 |
commit | 8753897edc7119065d210c6cef8b5a0a555d322b (patch) | |
tree | 9cf2fd20e1c1fa1d87b0d6b28fdbca0103c094cc | |
parent | da83d9e91d419e1c843e3017098d25dbde22b500 (diff) | |
download | gitbook-8753897edc7119065d210c6cef8b5a0a555d322b.zip gitbook-8753897edc7119065d210c6cef8b5a0a555d322b.tar.gz gitbook-8753897edc7119065d210c6cef8b5a0a555d322b.tar.bz2 |
Fix js error because of changing API
-rw-r--r-- | packages/gitbook-core/src/lib/createContext.js | 16 | ||||
-rw-r--r-- | packages/gitbook-core/src/lib/createPlugin.js | 2 | ||||
-rw-r--r-- | packages/gitbook-core/src/models/Plugin.js | 8 | ||||
-rw-r--r-- | packages/gitbook-core/src/models/SummaryArticle.js | 9 |
4 files changed, 25 insertions, 10 deletions
diff --git a/packages/gitbook-core/src/lib/createContext.js b/packages/gitbook-core/src/lib/createContext.js index 1b834e4..d19e0f6 100644 --- a/packages/gitbook-core/src/lib/createContext.js +++ b/packages/gitbook-core/src/lib/createContext.js @@ -2,16 +2,16 @@ const Redux = require('redux'); const ReduxThunk = require('redux-thunk').default; -const Plugin = require('./models/Plugin'); -const Context = require('./models/Context'); +const Plugin = require('../models/Plugin'); +const Context = require('../models/Context'); const coreReducers = require('../reducers'); const composeReducer = require('./composeReducer'); -const Components = require('./actions/components'); -const I18n = require('./actions/i18n'); -const Navigation = require('./actions/navigation'); +const Components = require('../actions/components'); +const I18n = require('../actions/i18n'); +const Navigation = require('../actions/navigation'); -const corePlugin = Plugin({ +const corePlugin = new Plugin({ reduce: coreReducers, actions: { Components, I18n, Navigation @@ -31,7 +31,7 @@ function createContext(plugins, initialState) { // Compose the reducer from core with plugins const pluginReducers = plugins.map(plugin => plugin.reduce); - const reducer = composeReducer(pluginReducers); + const reducer = composeReducer(...pluginReducers); // Get actions from all plugins const actions = plugins.reduce((accu, plugin) => { @@ -52,7 +52,7 @@ function createContext(plugins, initialState) { plugin.init(store.dispatch, store.getState, actions); }); - return Context({ + return new Context({ store, actions }); diff --git a/packages/gitbook-core/src/lib/createPlugin.js b/packages/gitbook-core/src/lib/createPlugin.js index f03bb94..a2a3f42 100644 --- a/packages/gitbook-core/src/lib/createPlugin.js +++ b/packages/gitbook-core/src/lib/createPlugin.js @@ -9,7 +9,7 @@ const Plugin = require('../models/Plugin'); * @return {Plugin} */ function createPlugin({ init, reduce, actions }) { - const plugin = Plugin({ + const plugin = new Plugin({ init, reduce, actions diff --git a/packages/gitbook-core/src/models/Plugin.js b/packages/gitbook-core/src/models/Plugin.js index 0654f85..7ca5a86 100644 --- a/packages/gitbook-core/src/models/Plugin.js +++ b/packages/gitbook-core/src/models/Plugin.js @@ -7,7 +7,13 @@ const DEFAULTS = { }; class Plugin extends Record(DEFAULTS) { - + constructor(plugin) { + super({ + init: plugin.init || DEFAULTS.init, + reduce: plugin.reduce || DEFAULTS.reduce, + actions: plugin.actions || DEFAULTS.actions + }); + } } module.exports = Plugin; diff --git a/packages/gitbook-core/src/models/SummaryArticle.js b/packages/gitbook-core/src/models/SummaryArticle.js index b36fbe3..80ef5ae 100644 --- a/packages/gitbook-core/src/models/SummaryArticle.js +++ b/packages/gitbook-core/src/models/SummaryArticle.js @@ -52,6 +52,15 @@ class SummaryArticle extends Record(DEFAULTS) { return filePath + (parts.hash || ''); } + + /** + * Return true if article is an instance of SummaryArticle + * @param {Mixed} article + * @return {Boolean} + */ + static is(article) { + return (article instanceof SummaryArticle); + } } module.exports = SummaryArticle; |