Question regarding stream scan behavior

17 views
Skip to first unread message

myth...@gmail.com

unread,
Sep 23, 2015, 6:43:10 PM9/23/15
to Bacon.js
If I do the following:

var a = new Bacon.Bus();
var b = a.scan(0, function(x,y) { return x + y; });

a.push(1);

b.onValue(function(value) {
console.log("-> ", value);
});

a.push(2);


I get:
-> 0
-> 2

instead of the expected:
-> 1
-> 3

However if I do a b.log() before the a.push(1) I get the expected result:

var a = new Bacon.Bus();
var b = a.scan(0, function(x,y) { return x + y; });
b.log();
a.push(1);
b.onValue(function(value) {
console.log("-> ", value);
});
a.push(2);

Gives me:

0
1
-> 1
3
-> 3


Is this a bug? Is it expected behaviour? Is there a way to get the behaviour I want without using b.log()?

Thank you for any advice!

Jeff

myth...@gmail.com

unread,
Sep 23, 2015, 6:49:18 PM9/23/15
to Bacon.js, myth...@gmail.com


And just read the FAQ and found information on this!

https://github.com/baconjs/bacon.js/wiki/FAQ

Thank you FAQ!

Reply all
Reply to author
Forward
0 new messages