Open jamesamcl opened 8 years ago
Currently thinking something like
obs(function(obj, versionID) {
if(versionID > cachedVersionID) {
// update and emit
for array and struct. Then increment the versionID and emit for each set on an Observ.
(Using something appropriate for versionID that can't overflow.)
Best explained by an example:
Output:
Once x -> 0 happens, the state is further mutated by the callback, but after this the first mutation is emitted to arr2, which stores the old state back in the array. Consequently both arrays contain the same observable, but track a different version of it.
Not really sure how to fix this. Maybe some kind of transaction ID that gets incremented for each change to prevent older copies of the state overwriting newer ones?