-
Notifications
You must be signed in to change notification settings - Fork 74
Open
Description
If you create an S.value
and update it multiple times before attaching any listeners, the Value erroneously reports conflicting values.
var foo = S.value(100);
foo(200); // Succeeds
foo(300);
// Error: conflicting values: 300 is not the same as 200
I believe this happens, because on line 267 the DataNode
does not cause to RootClock
to tick if it has no listeners. So S.value's age
is equal to the RootClock.time
causing the fault.
A fix would be to preserve the age
of the S.value
when RunningClock == null
and no listeners.
if (arguments.length === 0) {
return node.current();
}
else if(RunningClock === null && node.log === null) {
return current = node.next(update!);
} else {
var same = eq ? eq(current, update!) : current === update;
if (!same) {
var time = RootClock.time;
if (age === time)
throw new Error("conflicting values: " + update + " is not the same as " + current);
age = time;
current = update!;
node.next(update!);
}
return update!;
}
Qix-, TimHambourger and romme
Metadata
Metadata
Assignees
Labels
No labels