Signal
See source codeTable of contents
A Signal is a reactive value container. The value may change over time, and it may keep track of the diffs between sequential values.
There are two types of signal:
- Atomic signals, created using atom. These are mutable references to values that can be changed using Atom.set.
- Computed signals, created using . These are values that are computed from other signals. They are recomputed lazily if their dependencies change.
interface Signal<Value, Diff = unknown> {}
Properties
lastChangedEpoch
The epoch when this signal's value last changed. Note tha this is not the same as when the value was last computed. A signal may recopmute it's value without changing it.
lastChangedEpoch: number
name
The name of the signal. This is used at runtime for debugging and perf profiling only. It does not need to be globally unique.
name: string
Methods
get
The current value of the signal. This is a reactive value, and will update when the signal changes. Any computed signal that depends on this signal will be lazily recomputed if this signal changes. Any effect that depends on this signal will be rescheduled if this signal changes.
getDiffSince
Returns the sequence of diffs between the the value at the given epoch and the current value. Returns the constant if there is not enough information to compute the diff sequence.
Parameters
Name | Description |
---|---|
|
The epoch to get diffs since. |
Returns
Diff[] | RESET_VALUE