Readonly
$versionA version representation of the value.
If two versions of a val is not equal(Object.is
), it means the value
has changed (event if the value
is equal).
Get current value of the val.
Set new value
Current value of the val
Subscribe to value changes without immediate emission. The subscribers will be called before sync and async subscribers from [[reaction]] and [[subscribe]]. It is mainly used for chaining Vals.
a disposer function that cancels the subscription
Subscribe to value changes without immediate emission.
Optional
eager: booleanby default subscribers will be notified on next tick. set true
to notify subscribers of value changes synchronously.
a disposer function that cancels the subscription
Create a new ReadonlyVal referencing the value of the current ReadonlyVal as source.
(It is just like derive
a val without transform
. It is simpler hence more efficient.)
All ref ReadonlyVals share the same value from the source ReadonlyVal.
With this pattern you can pass a ref ReadonlyVal to downstream. The ref ReadonlyVals can be safely disposed without affecting the source ReadonlyVal and other ref ReadonlyVals.
Create a new ReadonlyVal referencing the value of the current ReadonlyVal as source.
(It is just like derive
a val without transform
. It is simpler hence more efficient.)
All ref ReadonlyVals share the same value from the source ReadonlyVal.
With this pattern you can pass a ref ReadonlyVal to downstream. The ref ReadonlyVals can be safely disposed without affecting the source ReadonlyVal and other ref ReadonlyVals.
Optional
writable: falseCreate a new Val referencing the value of the current Val as source. All ref Vals share the same value from the source Val. The act of setting a value on the ref Val is essentially setting the value on the source Val.
With this pattern you can pass a ref Val as a writable Val to downstream. The ref Vals can be safely disposed without affecting the source Val and other ref Vals.
Optional
writable: booleanIf true, creates a new Ref Val referencing the value of the current Val as source. If false, creates a new Ref ReadonlyVal referencing the value of the current Val as source.
Subscribe to value changes with immediate emission.
Optional
eager: booleanby default subscribers will be notified on next tick. set true
to notify subscribers of value changes synchronously.
a disposer function that cancels the subscription
A Val contains a writable
value
property and aset
method.