-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (28 loc) · 810 Bytes
/
index.js
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
30
'use strict';
var assign = require('lodash.assign');
module.exports = function fluxiblePluginActions(settings) {
settings = settings || {};
return {
name: 'fluxible-plugin-actions',
plugContext: function (options) {
options = options || {};
var _actions = assign({}, settings.actions || {}, options.actions || {});
return {
plugComponentContext: function (componentContext) {
componentContext.getAction = componentContext.getAction || function (action) {
return _actions[action];
}
},
dehydrate: function () {
return {
actions: _actions
};
},
rehydrate: function (state) {
state = state || {};
_actions = state.actions;
}
}
}
}
};