mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-10-02 23:18:11 +00:00
28 lines
651 B
JavaScript
28 lines
651 B
JavaScript
const Plugin = require('../models/Plugin');
|
|
|
|
/**
|
|
* Create a plugin to extend the state and the views.
|
|
*
|
|
* @param {Function(dispatch, state)} plugin.init
|
|
* @param {Function(state, action)} plugin.reduce
|
|
* @param {Object} plugin.actions
|
|
* @return {Plugin}
|
|
*/
|
|
function createPlugin({ activate, deactivate, reduce, actions }) {
|
|
const plugin = new Plugin({
|
|
activate,
|
|
deactivate,
|
|
reduce,
|
|
actions
|
|
});
|
|
|
|
if (typeof window !== 'undefined') {
|
|
window.gitbookPlugins = window.gitbookPlugins || [];
|
|
window.gitbookPlugins.push(plugin);
|
|
}
|
|
|
|
return plugin;
|
|
}
|
|
|
|
module.exports = createPlugin;
|