AtomOptions

See source code
Table of contents

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

interface AtomOptions<Value, Diff> {}

Properties

computeDiff

optional

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

optional

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

optional

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

NameDescription

a

any

The old value

b

any

The new value

Returns

boolean

Prev
Atom
Next
Computed

We use cookies on this website.
Learn more in our Cookie Policy.