The fact that bacon.js evaluates event values lazily is a bit confusing. This bit me in my Oredev presentation. So if I couldn't take that into account, how many new Bacon.js users will?
Now, if you do
fieldValue = $(".foo").asEventStream('keyup').map((e) => $(e.currentTarget).val()).toProperty()
firstClick = clicks.take(1)
secondClick = clicks.skip(1).take(2)
twoValues = Bacon.combineAsArray(
fieldValue.sampledBy(firstClick),
fieldValue.sampledBy(secondClick)
)
twoValues.log()
What do you get? An array of the values of the .foo textfield at the times of first and second click? Well, not exactly. You'll get the value of the textfield at the time of the second click, twice.
This is because the value of the events isn't evaluated until it's actually used. (see also https://github.com/baconjs/bacon.js/#lazy-evaluation)
Now the question is, should we remove lazy evaluation altogether in Bacon.js 0.8? My suggestion would be to make a spike and see if that brings any serious performance penalty. Then proceed accordingly.
The fact that bacon.js evaluates event values lazily is a bit confusing. This bit me in my Oredev presentation. So if I couldn't take that into account, how many new Bacon.js users will?
Now, if you do
What do you get? An array of the values of the
.footextfield at the times of first and second click? Well, not exactly. You'll get the value of the textfield at the time of the second click, twice.This is because the value of the events isn't evaluated until it's actually used. (see also https://github.com/baconjs/bacon.js/#lazy-evaluation)
Now the question is, should we remove lazy evaluation altogether in Bacon.js 0.8? My suggestion would be to make a spike and see if that brings any serious performance penalty. Then proceed accordingly.