Question regarding stream scan behavior

17 peržiūrų
Praleisti ir pereiti prie pirmo neskaityto pranešimo

myth...@gmail.com

neskaityta,
2015-09-23 18:43:102015-09-23
kam: 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

neskaityta,
2015-09-23 18:49:182015-09-23
kam: 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!

Atsakyti visiems
Atsakyti autoriui
Persiųsti
0 naujų pranešimų