AtomOptions
See source codeTable of contents
The options to configure an atom, passed into the atom function.
interface AtomOptions<Value, Diff> {}
Properties
computeDiff
A method used to compute a diff between the atom's old and new values. If provided, it will not be used unless you also specify AtomOptions.historyLength.
computeDiff?: ComputeDiff<Value, Diff>
historyLength
The maximum number of diffs to keep in the history buffer.
If you don't need to compute diffs, or if you will supply diffs manually via Atom.set, you can leave this as undefined
and no history buffer will be created.
If you expect the value to be part of an active effect subscription all the time, and to not change multiple times inside of a single transaction, you can set this to a relatively low number (e.g. 10).
Otherwise, set this to a higher number based on your usage pattern and memory constraints.
historyLength?: number
Methods
isEqual
If provided, this will be used to compare the old and new values of the atom to determine if the value has changed.
By default, values are compared using first using strict equality (===
), then Object.is
, and finally any .equals
method present in the object's prototype chain.
Parameters
Name | Description |
---|---|
|
The old value |
|
The new value |
Returns
boolean