-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (29 loc) · 698 Bytes
/
index.js
File metadata and controls
32 lines (29 loc) · 698 Bytes
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
31
32
const mutate = require('xtend/mutable')
module.exports = createModel
// module creation helper
// (str?) -> obj
function createModel (namespace) {
const model = (namespace) ? { namespace: namespace } : {}
model.models = {}
model.reducers = {}
model.effects = {}
model.subscriptions = {}
model.state = {}
return {
start: function () {
return model
},
state: function (value) {
mutate(model.state, value)
},
reducer: function (key, value) {
model.reducers[key] = value
},
subscription: function (key, value) {
model.subscriptions[key] = value
},
effect: function (key, value) {
model.effects[key] = value
}
}
}