git ssb

0+

Dominic / %DqZuyvY14e7IX0U6cAj…



Tree: 6b099fb2cf92d238df76e99ebab6e3a13c9149d0

Files: 6b099fb2cf92d238df76e99ebab6e3a13c9149d0 / index.js

443 bytesRaw
1var evolve = require('./evolve')
2
3module.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