WithDiff
See source codeA singleton class used to wrap computed signal values along with their diffs. This class is used internally by the withDiff function to provide both the computed value and its diff to the signal system.
WithDiff: {
new <Value, Diff>(
value: Value,
diff: Diff
): {
diff: Diff
value: Value
}
}
Example
const count = atom('count', 0)
const double = computed('double', (prevValue) => {
const nextValue = count.get() * 2
if (isUninitialized(prevValue)) {
return nextValue
}
return withDiff(nextValue, nextValue - prevValue)
})
Prev
UNINITIALIZEDNext
TLSyncErrorCloseEventCode