The .combine method has a feature that allows one to pass "passive sources" in a second array (see docs). One of original purposes of this feature was to allow to create "atomic update" behavior manually.
But turns out it doesn't work well with this use case as for now, for instance:
var a = Kefir.sequentially(100, [1,2,3]);
var b = a.map(function(val){return val + 2});
var c = a.map(function(val){return val * 2});
var d = Kefir.combine([b], [c], function(b, c){return [b,c]});
d.log()
Combine {_dispatcher: Dispatcher, _active: true, _alive: true, _activeCount: 1, _sources: Array[2]…}
// expecting [3, 2]
kefir.js:841 [combine] <value> [4, 2] // expecting [4, 4]
kefir.js:841 [combine] <value> [5, 4] // expecting [5, 6]
kefir.js:843 [combine] <end>
This happened after we deprecated Kefir.sampledBy(passive, active, fn) and introduced passive arg in Kefir.combine but in different order — Kefir.combine(active, passive, fn). The order change has introduced the issue. And as deprecated Kefir.sampledBy also implemented on top of Kefir.combine the issue is present in it too.
97 — issue about atomic updates.
The
.combine
method has a feature that allows one to pass "passive sources" in a second array (see docs). One of original purposes of this feature was to allow to create "atomic update" behavior manually.But turns out it doesn't work well with this use case as for now, for instance:
This happened after we deprecated
Kefir.sampledBy(passive, active, fn)
and introducedpassive
arg inKefir.combine
but in different order —Kefir.combine(active, passive, fn)
. The order change has introduced the issue. And as deprecatedKefir.sampledBy
also implemented on top ofKefir.combine
the issue is present in it too.