Last active
December 17, 2015 13:48
-
-
Save yarax/9161634927da523bb04c to your computer and use it in GitHub Desktop.
Reactive summary comparison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Bacon = require('baconjs'); | |
var Rx = require('rx'); | |
var Kefir = require('kefir'); | |
var EE = require('events').EventEmitter; | |
var ee = new EE; | |
var sum = function (prev, cur) {return prev+cur}; | |
Bacon.fromEvent(ee, 'event1').scan(0, sum).onValue(console.log); // 0, 4, 9 | |
Rx.Observable.fromEvent(ee, 'event1').reduce(sum, 0).subscribe(console.log); // doesn't work | |
Kefir.fromEvents(ee, 'event1').scan(sum, 0).onValue(console.log); // 0, 4, 9 | |
ee.emit('event1', 4); | |
ee.emit('event1', 5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment