Skip to main content

AtomOptions<Value, Diff>

The options to configure an atom, passed into the atom function.

Type parameters

  • Value
  • Diff

Index

Properties

Properties

computeDiff?

ComputeDiff<Value, Diff>

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.

Defined in: signia/src/Atom.ts:27

historyLength?

number

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.

Defined in: signia/src/Atom.ts:23

isEqual?

Function

Type declaration

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.

Signature
(a: any, b: any): boolean;
Parameters
NameType
aany
bany
Returns

boolean

Defined in: signia/src/Atom.ts:35