summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-core/src/models/Plugin.js
blob: 7ca5a8640ffb35c9a566180dcf5689b84db011dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const { Record } = require('immutable');

const DEFAULTS = {
    init:   ((dispatch, getState) => {}),
    reduce: ((state, action) => state),
    actions: {}
};

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;