Files: 28ed9bebf2904e28107d97a89d40b4e12b753fe3 / index.js
443 bytesRaw
1 | var evolve = require('./evolve') |
2 | |
3 | module.exports = function (update, _act, state) { |
4 | var acting = false |
5 | var events = [] |
6 | function cause (ev) { |
7 | events.push(ev) |
8 | if(!acting) run() |
9 | } |
10 | |
11 | function act (state, effect) { |
12 | return _act(state, effect, cause) |
13 | } |
14 | |
15 | function run () { |
16 | acting = true |
17 | state = evolve(update, act, state, events) |
18 | acting = false |
19 | } |
20 | |
21 | return function (ev) { |
22 | cause(ev) |
23 | return state |
24 | } |
25 | |
26 | } |
27 | |
28 |
Built with git-ssb-web