summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-core/src/models/Context.js
blob: fa68bd8b609379afe6b24785c463595f5ee7d34e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const { Record } = require('immutable');

const DEFAULTS = {
    store: null,
    actions: {}
};

class Context extends Record(DEFAULTS) {

    /**
     * Return current state
     * @return {Object}
     */
    getState() {
        const { store } = this;
        return store.getState();
    }

    /**
     * Dispatch an action
     * @param {Action} action
     */
    dispatch(action) {
        const { store } = this;
        return store.dispatch(action);
    }
}

module.exports = Context;