Bacon.js是一个小型JavaScript函数式响应编程库。
简单代码示例:
var up = $('#up').asEventStream('click');var down = $('#down').asEventStream('click');var counter = // map up to 1, down to -1 up.map(1).merge(down.map(-1)) // accumulate sum .scan(0, function(x,y) { return x + y });// assign observable value to jQuery property textcounter.assign($('#counter'), 'text');
评论