Can't create working Bacon.Models inside handlers for "map" type functions
metrip opened this issue · comments
Working:
Bacon.once(1)
.map(function(v) { console.log(Bacon.Model(2).get()); return v; })
.log();
2
1
<end>
Not working:
Bacon.once(1)
.map(function(v) { console.log(Bacon.Model(2).get()); return v; })
.skipDuplicates()
.log();
undefined
1
<end>
Bacon.once(1)
.flatMap(function(v) { console.log(Bacon.Model(2).get()); return v; })
.log();
undefined
1
<end>
Bacon.once(1)
.flatMapLatest(function(v) { console.log(Bacon.Model(2).get()); return v; })
.log();
undefined
1
<end>
This is really a bacon.model issue. Creating a model inside an "event transaction" and using the get
method immediately could be fixed by setting the currentValue
variable in the Model
constructor. Are you interested in writing a failing test case for this problem in the Bacon.Model codebase?