Skip to content

Package @reatom/primitives

@reatom/primitives

Interfaces

ArrayAtom()<T>

Defined in: primitives/reatomArray.ts:4

Base changeable state container.

Atom is the core primitive for storing and updating mutable state in Reatom. It can be called to retrieve its current state or update it with a new value or update function.

Extends

Type Parameters

T

T

The type of state stored in the atom

ArrayAtom(…params): T[]

Defined in: primitives/reatomArray.ts:4

Base changeable state container.

Atom is the core primitive for storing and updating mutable state in Reatom. It can be called to retrieve its current state or update it with a new value or update function.

Parameters

params

…[]

Parameters to pass to the atom

Returns

T[]

The atom’s payload (typically its current state)

Properties

__reatom

__reatom: AtomMeta

Defined in: core/atom.ts:106

Reference to the atom’s internal metadata.

Inherited from

Atom.__reatom

actions

actions: Actions<ArrayAtom<T>>

Defined in: core/atom.ts:86

Bind methods to the atom to extend its functionality.

Deprecated

Use extend instead

Inherited from

Atom.actions

extend

extend: Extend<ArrayAtom<T>>

Defined in: core/atom.ts:92

Extension system to add capabilities to atoms. Allows adding middleware, methods, or other functionality to modify atom behavior.

Inherited from

Atom.extend

pop

pop: Action<[], undefined | T>

Defined in: primitives/reatomArray.ts:6

push

push: Action<T[], number>

Defined in: primitives/reatomArray.ts:5

shift

shift: Action<[], undefined | T>

Defined in: primitives/reatomArray.ts:7

subscribe()

subscribe: (cb?) => Unsubscribe

Defined in: core/atom.ts:103

Subscribe to state changes, with the first call happening immediately. When a subscriber is added, the callback is immediately invoked with the current state. After that, it’s called whenever the atom’s state changes.

Parameters
cb?

(state) => any

Callback function that receives the atom’s state when it changes

Returns

Unsubscribe

An unsubscribe function that removes the subscription when called

Inherited from

Atom.subscribe

unshift

unshift: Action<T[], number>

Defined in: primitives/reatomArray.ts:8

Methods

set()
Call Signature

set(update): T[]

Defined in: core/atom.ts:127

Update the atom’s state using a function that receives the previous state

Parameters
update

(state) => T[]

Function that takes the current state and returns a new state

Returns

T[]

The new state value

Inherited from

Atom.set

Call Signature

set(…params): T[]

Defined in: core/atom.ts:135

Set the atom’s state to a new value

Parameters
params

…[T[]]

Returns

T[]

The new state value

Inherited from

Atom.set


BooleanAtom()

Defined in: primitives/reatomBoolean.ts:4

Base changeable state container.

Atom is the core primitive for storing and updating mutable state in Reatom. It can be called to retrieve its current state or update it with a new value or update function.

Extends

BooleanAtom(…params): boolean

Defined in: primitives/reatomBoolean.ts:4

Base changeable state container.

Atom is the core primitive for storing and updating mutable state in Reatom. It can be called to retrieve its current state or update it with a new value or update function.

Parameters

params

…[]

Parameters to pass to the atom

Returns

boolean

The atom’s payload (typically its current state)

Properties

__reatom

__reatom: AtomMeta

Defined in: core/atom.ts:106

Reference to the atom’s internal metadata.

Inherited from

Atom.__reatom

actions

actions: Actions<BooleanAtom>

Defined in: core/atom.ts:86

Bind methods to the atom to extend its functionality.

Deprecated

Use extend instead

Inherited from

Atom.actions

extend

extend: Extend<BooleanAtom>

Defined in: core/atom.ts:92

Extension system to add capabilities to atoms. Allows adding middleware, methods, or other functionality to modify atom behavior.

Inherited from

Atom.extend

reset

reset: Action<[], boolean>

Defined in: primitives/reatomBoolean.ts:8

setFalse

setFalse: Action<[], false>

Defined in: primitives/reatomBoolean.ts:7

setTrue

setTrue: Action<[], true>

Defined in: primitives/reatomBoolean.ts:6

subscribe()

subscribe: (cb?) => Unsubscribe

Defined in: core/atom.ts:103

Subscribe to state changes, with the first call happening immediately. When a subscriber is added, the callback is immediately invoked with the current state. After that, it’s called whenever the atom’s state changes.

Parameters
cb?

(state) => any

Callback function that receives the atom’s state when it changes

Returns

Unsubscribe

An unsubscribe function that removes the subscription when called

Inherited from

Atom.subscribe

toggle

toggle: Action<[], boolean>

Defined in: primitives/reatomBoolean.ts:5

Methods

set()
Call Signature

set(update): boolean

Defined in: core/atom.ts:127

Update the atom’s state using a function that receives the previous state

Parameters
update

(state) => boolean

Function that takes the current state and returns a new state

Returns

boolean

The new state value

Inherited from

Atom.set

Call Signature

set(…params): boolean

Defined in: core/atom.ts:135

Set the atom’s state to a new value

Parameters
params

…[boolean]

Returns

boolean

The new state value

Inherited from

Atom.set


LinkedList<Node>

Defined in: primitives/reatomLinkedList.ts:30

Extended by

Type Parameters

Node

Node extends LLNode = LLNode

Properties

changes

changes: LLChanges<Node>[]

Defined in: primitives/reatomLinkedList.ts:35

head: null | Node

Defined in: primitives/reatomLinkedList.ts:31

size

size: number

Defined in: primitives/reatomLinkedList.ts:33

tail

tail: null | Node

Defined in: primitives/reatomLinkedList.ts:32

version

version: number

Defined in: primitives/reatomLinkedList.ts:34


LinkedListAtom()<Params, Node, Key>

Defined in: primitives/reatomLinkedList.ts:45

Base changeable state container.

Atom is the core primitive for storing and updating mutable state in Reatom. It can be called to retrieve its current state or update it with a new value or update function.

Extends

Type Parameters

Params

Params extends any[] = any[]

The type of state stored in the atom

Node

Node extends Rec = Rec

Key

Key extends keyof Node = never

LinkedListAtom(…params): LinkedList

Defined in: primitives/reatomLinkedList.ts:45

Base changeable state container.

Atom is the core primitive for storing and updating mutable state in Reatom. It can be called to retrieve its current state or update it with a new value or update function.

Parameters

params

…[]

Parameters to pass to the atom

Returns

LinkedList

The atom’s payload (typically its current state)

Properties

__reatom

__reatom: AtomMeta

Defined in: core/atom.ts:106

Reference to the atom’s internal metadata.

Inherited from

LinkedListLikeAtom.__reatom

__reatomLinkedList

__reatomLinkedList: true

Defined in: primitives/reatomLinkedList.ts:42

Inherited from

LinkedListLikeAtom.__reatomLinkedList

actions

actions: Actions<LinkedListAtom<Params, Node, Key>>

Defined in: core/atom.ts:86

Bind methods to the atom to extend its functionality.

Deprecated

Use extend instead

Inherited from

LinkedListLikeAtom.actions

array

array: Computed<LLNode<Node>[]>

Defined in: primitives/reatomLinkedList.ts:40

Inherited from

LinkedListLikeAtom.array

batch

batch: Action<[Fn]>

Defined in: primitives/reatomLinkedList.ts:50

clear

clear: Action<[], void>

Defined in: primitives/reatomLinkedList.ts:56

create

create: Action<Params, LLNode<Node>>

Defined in: primitives/reatomLinkedList.ts:52

extend

extend: Extend<LinkedListAtom<Params, Node, Key>>

Defined in: core/atom.ts:92

Extension system to add capabilities to atoms. Allows adding middleware, methods, or other functionality to modify atom behavior.

Inherited from

LinkedListLikeAtom.extend

find()

find: (cb) => null | LLNode<Node>

Defined in: primitives/reatomLinkedList.ts:58

Parameters
cb

(node) => boolean

Returns

null | LLNode<Node>

initiateFromSnapshot()

initiateFromSnapshot: (initSnapshot) => LinkedList<LLNode<Node>>

Defined in: primitives/reatomLinkedList.ts:67

Parameters
initSnapshot

Params[]

Returns

LinkedList<LLNode<Node>>

initiateFromState()

initiateFromState: (initState) => LinkedList<LLNode<Node>>

Defined in: primitives/reatomLinkedList.ts:66

Parameters
initState

Node[]

Returns

LinkedList<LLNode<Node>>

map

map: Key extends never ? never : Atom<Map<State<Node[Key]>, LLNode<Node>>, [Map<State<Node[Key]>, LLNode<Node>>]>

Defined in: primitives/reatomLinkedList.ts:64

This lazy map is useful for working with serializable identifier, but it is not recommended to use it for large (thousands elements) lists

move

move: Action<[LLNode<Node>, null | LLNode<Node>], void>

Defined in: primitives/reatomLinkedList.ts:55

reatomMap()

reatomMap: <T>(cb, options?) => LinkedListDerivedAtom<LLNode<Node>, LLNode<T>>

Defined in: primitives/reatomLinkedList.ts:71

Type Parameters
T

T extends Rec

Parameters
cb

(node) => T

options?

string | { name?: string; onClear?: (lastState) => void; onCreate?: (node) => void; onMove?: (node) => void; onRemove?: (node, origin) => void; onSwap?: (payload) => void; }

Returns

LinkedListDerivedAtom<LLNode<Node>, LLNode<T>>

remove

remove: Action<[LLNode<Node>], boolean>

Defined in: primitives/reatomLinkedList.ts:53

subscribe()

subscribe: (cb?) => Unsubscribe

Defined in: core/atom.ts:103

Subscribe to state changes, with the first call happening immediately. When a subscriber is added, the callback is immediately invoked with the current state. After that, it’s called whenever the atom’s state changes.

Parameters
cb?

(state) => any

Callback function that receives the atom’s state when it changes

Returns

Unsubscribe

An unsubscribe function that removes the subscription when called

Inherited from

LinkedListLikeAtom.subscribe

swap

swap: Action<[LLNode<Node>, LLNode<Node>], void>

Defined in: primitives/reatomLinkedList.ts:54

Methods

set()
Call Signature

set(update): LinkedList

Defined in: core/atom.ts:127

Update the atom’s state using a function that receives the previous state

Parameters
update

(state) => LinkedList

Function that takes the current state and returns a new state

Returns

LinkedList

The new state value

Inherited from

LinkedListLikeAtom.set

Call Signature

set(…params): LinkedList

Defined in: core/atom.ts:135

Set the atom’s state to a new value

Parameters
params

…[LinkedList<LLNode<Node>>]

Returns

LinkedList

The new state value

Inherited from

LinkedListLikeAtom.set


LinkedListDerivedAtom()<Node, T>

Defined in: primitives/reatomLinkedList.ts:108

Derived state container.

A computed atom automatically tracks dependencies and recalculates only when those dependencies change. The calculation is performed lazily, only when the computed value is read AND subscribed to.

Extends

Type Parameters

Node

Node extends LLNode

The type of derived state

T

T extends LLNode

LinkedListDerivedAtom(…params): LinkedListDerivedState

Defined in: primitives/reatomLinkedList.ts:108

Derived state container.

A computed atom automatically tracks dependencies and recalculates only when those dependencies change. The calculation is performed lazily, only when the computed value is read AND subscribed to.

Parameters

params

…[]

Parameters to pass to the atom

Returns

LinkedListDerivedState

The atom’s payload (typically its current state)

Properties

__reatom

__reatom: AtomMeta

Defined in: core/atom.ts:106

Reference to the atom’s internal metadata.

Inherited from

Computed.__reatom

__reatomLinkedList

__reatomLinkedList: true

Defined in: primitives/reatomLinkedList.ts:112

actions

actions: Actions<LinkedListDerivedAtom<Node, T>>

Defined in: core/atom.ts:86

Bind methods to the atom to extend its functionality.

Deprecated

Use extend instead

Inherited from

Computed.actions

array

array: Computed<T extends LinkedList<LLNode> ? LLNode : never[]>

Defined in: primitives/reatomLinkedList.ts:110

extend

extend: Extend<LinkedListDerivedAtom<Node, T>>

Defined in: core/atom.ts:92

Extension system to add capabilities to atoms. Allows adding middleware, methods, or other functionality to modify atom behavior.

Inherited from

Computed.extend

set

set: unknown

Defined in: core/atom.ts:79

Inherited from

Computed.set

subscribe()

subscribe: (cb?) => Unsubscribe

Defined in: core/atom.ts:103

Subscribe to state changes, with the first call happening immediately. When a subscriber is added, the callback is immediately invoked with the current state. After that, it’s called whenever the atom’s state changes.

Parameters
cb?

(state) => any

Callback function that receives the atom’s state when it changes

Returns

Unsubscribe

An unsubscribe function that removes the subscription when called

Inherited from

Computed.subscribe


LinkedListDerivedState<Node, T>

Defined in: primitives/reatomLinkedList.ts:103

Extends

Type Parameters

Node

Node extends LLNode

T

T extends LLNode

Properties

changes

changes: LLChanges<T>[]

Defined in: primitives/reatomLinkedList.ts:35

Inherited from

LinkedList.changes

head

head: null | T

Defined in: primitives/reatomLinkedList.ts:31

Inherited from

LinkedList.head

map

map: WeakMap<Node, T>

Defined in: primitives/reatomLinkedList.ts:105

size

size: number

Defined in: primitives/reatomLinkedList.ts:33

Inherited from

LinkedList.size

tail

tail: null | T

Defined in: primitives/reatomLinkedList.ts:32

Inherited from

LinkedList.tail

version

version: number

Defined in: primitives/reatomLinkedList.ts:34

Inherited from

LinkedList.version


LinkedListLikeAtom()<T>

Defined in: primitives/reatomLinkedList.ts:38

Base changeable state container.

Atom is the core primitive for storing and updating mutable state in Reatom. It can be called to retrieve its current state or update it with a new value or update function.

Extends

Extended by

Type Parameters

T

T extends LinkedList = LinkedList

The type of state stored in the atom

LinkedListLikeAtom(…params): T

Defined in: primitives/reatomLinkedList.ts:38

Base changeable state container.

Atom is the core primitive for storing and updating mutable state in Reatom. It can be called to retrieve its current state or update it with a new value or update function.

Parameters

params

…[]

Parameters to pass to the atom

Returns

T

The atom’s payload (typically its current state)

Properties

__reatom

__reatom: AtomMeta

Defined in: core/atom.ts:106

Reference to the atom’s internal metadata.

Inherited from

Atom.__reatom

__reatomLinkedList

__reatomLinkedList: true

Defined in: primitives/reatomLinkedList.ts:42

actions

actions: Actions<LinkedListLikeAtom<T>>

Defined in: core/atom.ts:86

Bind methods to the atom to extend its functionality.

Deprecated

Use extend instead

Inherited from

Atom.actions

array

array: Computed<T extends LinkedList<LLNode> ? LLNode : never[]>

Defined in: primitives/reatomLinkedList.ts:40

extend

extend: Extend<LinkedListLikeAtom<T>>

Defined in: core/atom.ts:92

Extension system to add capabilities to atoms. Allows adding middleware, methods, or other functionality to modify atom behavior.

Inherited from

Atom.extend

subscribe()

subscribe: (cb?) => Unsubscribe

Defined in: core/atom.ts:103

Subscribe to state changes, with the first call happening immediately. When a subscriber is added, the callback is immediately invoked with the current state. After that, it’s called whenever the atom’s state changes.

Parameters
cb?

(state) => any

Callback function that receives the atom’s state when it changes

Returns

Unsubscribe

An unsubscribe function that removes the subscription when called

Inherited from

Atom.subscribe

Methods

set()
Call Signature

set(update): T

Defined in: core/atom.ts:127

Update the atom’s state using a function that receives the previous state

Parameters
update

(state) => T

Function that takes the current state and returns a new state

Returns

T

The new state value

Inherited from

Atom.set

Call Signature

set(…params): T

Defined in: core/atom.ts:135

Set the atom’s state to a new value

Parameters
params

…[T]

Returns

T

The new state value

Inherited from

Atom.set


MapAtom()<Key, Value>

Defined in: primitives/reatomMap.ts:11

Base atom interface for other userspace implementations. This is the core interface that all atom-like objects implement, providing the foundation for Reatom’s reactivity system.

Extends

Type Parameters

Key

Key

The type of state stored in the atom

Value

Value

MapAtom(…params): Map

Defined in: primitives/reatomMap.ts:11

Base atom interface for other userspace implementations. This is the core interface that all atom-like objects implement, providing the foundation for Reatom’s reactivity system.

Parameters

params

…[]

Parameters to pass to the atom

Returns

Map

The atom’s payload (typically its current state)

Properties

__reatom

__reatom: AtomMeta

Defined in: core/atom.ts:106

Reference to the atom’s internal metadata.

Inherited from

AtomLike.__reatom

actions

actions: Actions<MapAtom<Key, Value>>

Defined in: core/atom.ts:86

Bind methods to the atom to extend its functionality.

Deprecated

Use extend instead

Inherited from

AtomLike.actions

clear

clear: Action<[], Map<Key, Value>>

Defined in: primitives/reatomMap.ts:35

delete

delete: Action<[Key], Map<Key, Value>>

Defined in: primitives/reatomMap.ts:34

extend

extend: Extend<MapAtom<Key, Value>>

Defined in: core/atom.ts:92

Extension system to add capabilities to atoms. Allows adding middleware, methods, or other functionality to modify atom behavior.

Inherited from

AtomLike.extend

getOrCreate()

getOrCreate: (key, creator) => Value

Defined in: primitives/reatomMap.ts:31

Parameters
key

Key

creator

() => Value

Returns

Value

reset

reset: Action<[], Map<Key, Value>>

Defined in: primitives/reatomMap.ts:36

set

set: Action<[Key, Value], Map<Key, Value>>

Defined in: primitives/reatomMap.ts:33

Overrides

AtomLike.set

size

size: Computed<number>

Defined in: primitives/reatomMap.ts:38

subscribe()

subscribe: (cb?) => Unsubscribe

Defined in: core/atom.ts:103

Subscribe to state changes, with the first call happening immediately. When a subscriber is added, the callback is immediately invoked with the current state. After that, it’s called whenever the atom’s state changes.

Parameters
cb?

(state) => any

Callback function that receives the atom’s state when it changes

Returns

Unsubscribe

An unsubscribe function that removes the subscription when called

Inherited from

AtomLike.subscribe

Methods

setState()
Call Signature

setState(update): Map<Key, Value>

Defined in: primitives/reatomMap.ts:19

Update the atom’s state using a function that receives the previous state

Parameters
update

(state) => StateInit<Key, Value>

Function that takes the current state and returns a new state

Returns

Map<Key, Value>

The new state value

Call Signature

setState(newState): Map<Key, Value>

Defined in: primitives/reatomMap.ts:29

Set the atom’s state to a new value

Parameters
newState

StateInit<Key, Value>

The new state value

Returns

Map<Key, Value>

The new state value


NumberAtom()

Defined in: primitives/reatomNumber.ts:5

Base changeable state container.

Atom is the core primitive for storing and updating mutable state in Reatom. It can be called to retrieve its current state or update it with a new value or update function.

Extends

NumberAtom(…params): number

Defined in: primitives/reatomNumber.ts:5

Base changeable state container.

Atom is the core primitive for storing and updating mutable state in Reatom. It can be called to retrieve its current state or update it with a new value or update function.

Parameters

params

…[]

Parameters to pass to the atom

Returns

number

The atom’s payload (typically its current state)

Properties

__reatom

__reatom: AtomMeta

Defined in: core/atom.ts:106

Reference to the atom’s internal metadata.

Inherited from

Atom.__reatom

actions

actions: Actions<NumberAtom>

Defined in: core/atom.ts:86

Bind methods to the atom to extend its functionality.

Deprecated

Use extend instead

Inherited from

Atom.actions

decrement

decrement: Action<[number], number>

Defined in: primitives/reatomNumber.ts:7

extend

extend: Extend<NumberAtom>

Defined in: core/atom.ts:92

Extension system to add capabilities to atoms. Allows adding middleware, methods, or other functionality to modify atom behavior.

Inherited from

Atom.extend

increment

increment: Action<[number], number>

Defined in: primitives/reatomNumber.ts:6

random

random: Action<[number, number], number>

Defined in: primitives/reatomNumber.ts:8

reset

reset: Action<[], number>

Defined in: primitives/reatomNumber.ts:9

subscribe()

subscribe: (cb?) => Unsubscribe

Defined in: core/atom.ts:103

Subscribe to state changes, with the first call happening immediately. When a subscriber is added, the callback is immediately invoked with the current state. After that, it’s called whenever the atom’s state changes.

Parameters
cb?

(state) => any

Callback function that receives the atom’s state when it changes

Returns

Unsubscribe

An unsubscribe function that removes the subscription when called

Inherited from

Atom.subscribe

Methods

set()
Call Signature

set(update): number

Defined in: core/atom.ts:127

Update the atom’s state using a function that receives the previous state

Parameters
update

(state) => number

Function that takes the current state and returns a new state

Returns

number

The new state value

Inherited from

Atom.set

Call Signature

set(…params): number

Defined in: core/atom.ts:135

Set the atom’s state to a new value

Parameters
params

…[number]

Returns

number

The new state value

Inherited from

Atom.set


RecordAtom()<T>

Defined in: primitives/reatomRecord.ts:6

Base changeable state container.

Atom is the core primitive for storing and updating mutable state in Reatom. It can be called to retrieve its current state or update it with a new value or update function.

Extends

Type Parameters

T

T extends Rec

The type of state stored in the atom

RecordAtom(…params): T

Defined in: primitives/reatomRecord.ts:6

Base changeable state container.

Atom is the core primitive for storing and updating mutable state in Reatom. It can be called to retrieve its current state or update it with a new value or update function.

Parameters

params

…[]

Parameters to pass to the atom

Returns

T

The atom’s payload (typically its current state)

Properties

__reatom

__reatom: AtomMeta

Defined in: core/atom.ts:106

Reference to the atom’s internal metadata.

Inherited from

Atom.__reatom

actions

actions: Actions<RecordAtom<T>>

Defined in: core/atom.ts:86

Bind methods to the atom to extend its functionality.

Deprecated

Use extend instead

Inherited from

Atom.actions

extend

extend: Extend<RecordAtom<T>>

Defined in: core/atom.ts:92

Extension system to add capabilities to atoms. Allows adding middleware, methods, or other functionality to modify atom behavior.

Inherited from

Atom.extend

merge

merge: Action<[Partial<T>], T>

Defined in: primitives/reatomRecord.ts:7

omit

omit: Action<keyof T[], T>

Defined in: primitives/reatomRecord.ts:8

reset

reset: Action<keyof T[], T>

Defined in: primitives/reatomRecord.ts:9

subscribe()

subscribe: (cb?) => Unsubscribe

Defined in: core/atom.ts:103

Subscribe to state changes, with the first call happening immediately. When a subscriber is added, the callback is immediately invoked with the current state. After that, it’s called whenever the atom’s state changes.

Parameters
cb?

(state) => any

Callback function that receives the atom’s state when it changes

Returns

Unsubscribe

An unsubscribe function that removes the subscription when called

Inherited from

Atom.subscribe

Methods

set()
Call Signature

set(update): T

Defined in: core/atom.ts:127

Update the atom’s state using a function that receives the previous state

Parameters
update

(state) => T

Function that takes the current state and returns a new state

Returns

T

The new state value

Inherited from

Atom.set

Call Signature

set(…params): T

Defined in: core/atom.ts:135

Set the atom’s state to a new value

Parameters
params

…[T]

Returns

T

The new state value

Inherited from

Atom.set


SetAtom()<T>

Defined in: primitives/reatomSet.ts:8

Base changeable state container.

Atom is the core primitive for storing and updating mutable state in Reatom. It can be called to retrieve its current state or update it with a new value or update function.

Extends

  • Atom<Set<T>, [StateInit<T>]>

Type Parameters

T

T

The type of state stored in the atom

SetAtom(…params): Set

Defined in: primitives/reatomSet.ts:8

Base changeable state container.

Atom is the core primitive for storing and updating mutable state in Reatom. It can be called to retrieve its current state or update it with a new value or update function.

Parameters

params

…[]

Parameters to pass to the atom

Returns

Set

The atom’s payload (typically its current state)

Properties

__reatom

__reatom: AtomMeta

Defined in: core/atom.ts:106

Reference to the atom’s internal metadata.

Inherited from

Atom.__reatom

actions

actions: Actions<SetAtom<T>>

Defined in: core/atom.ts:86

Bind methods to the atom to extend its functionality.

Deprecated

Use extend instead

Inherited from

Atom.actions

add

add: Action<[T], Set<T>>

Defined in: primitives/reatomSet.ts:9

clear

clear: Action<[], Set<T>>

Defined in: primitives/reatomSet.ts:12

delete

delete: Action<[T], Set<T>>

Defined in: primitives/reatomSet.ts:10

extend

extend: Extend<SetAtom<T>>

Defined in: core/atom.ts:92

Extension system to add capabilities to atoms. Allows adding middleware, methods, or other functionality to modify atom behavior.

Inherited from

Atom.extend

reset

reset: Action<[], Set<T>>

Defined in: primitives/reatomSet.ts:13

size

size: Computed<number>

Defined in: primitives/reatomSet.ts:14

subscribe()

subscribe: (cb?) => Unsubscribe

Defined in: core/atom.ts:103

Subscribe to state changes, with the first call happening immediately. When a subscriber is added, the callback is immediately invoked with the current state. After that, it’s called whenever the atom’s state changes.

Parameters
cb?

(state) => any

Callback function that receives the atom’s state when it changes

Returns

Unsubscribe

An unsubscribe function that removes the subscription when called

Inherited from

Atom.subscribe

toggle

toggle: Action<[T], Set<T>>

Defined in: primitives/reatomSet.ts:11

Methods

set()
Call Signature

set(update): Set

Defined in: core/atom.ts:127

Update the atom’s state using a function that receives the previous state

Parameters
update

(state) => Set

Function that takes the current state and returns a new state

Returns

Set

The new state value

Inherited from

Atom.set

Call Signature

set(…params): Set

Defined in: core/atom.ts:135

Set the atom’s state to a new value

Parameters
params

…[StateInit<T>]

Returns

Set

The new state value

Inherited from

Atom.set

Type Aliases

EnumAtom<T, Format>

EnumAtom<T, Format> = Atom<T> & EnumVariantSetters<T, Format> & object

Defined in: primitives/reatomEnum.ts:15

Type declaration

enum

enum: { [K in T]: K }

reset

reset: Action<[], T>

Type Parameters

T

T extends string

Format

Format extends EnumFormat = "camelCase"


EnumAtomOptions<T, Format>

EnumAtomOptions<T, Format> = object

Defined in: primitives/reatomEnum.ts:24

Type Parameters

T

T extends string

Format

Format extends EnumFormat = "camelCase"

Properties

format?

optional format: Format

Defined in: primitives/reatomEnum.ts:29

initState?

optional initState: T

Defined in: primitives/reatomEnum.ts:30

name?

optional name: string

Defined in: primitives/reatomEnum.ts:28


EnumFormat

EnumFormat = "camelCase" | "snake_case"

Defined in: primitives/reatomEnum.ts:5


LLNode<T>

LLNode<T> = T & object

Defined in: primitives/reatomLinkedList.ts:18

Linked List is reusing the model reference to simplify the reference sharing and using it as a key of LL methods. Btw, symbols works fine with serialization and will not add a garbage to an output.

Type declaration

[LL_NEXT]

[LL_NEXT]: null | LLNode<T>

[LL_PREV]

[LL_PREV]: null | LLNode<T>

Type Parameters

T

T extends Rec = Rec


StringAtom<T>

StringAtom<T> = Atom<T> & object

Defined in: primitives/reatomString.ts:4

Type declaration

reset

reset: Action<[], T>

Type Parameters

T

T extends string = string

Variables

reatomString()

const reatomString: {(init?, name?): StringAtom; <T>(init, name?): StringAtom<T>; }

Defined in: primitives/reatomString.ts:8

Call Signature

(init?, name?): StringAtom

Parameters
init?

string

name?

string

Returns

StringAtom

Call Signature

<T>(init, name?): StringAtom<T>

Type Parameters
T

T extends string

Parameters
init

T

name?

string

Returns

StringAtom<T>

Functions

isLinkedListAtom()

isLinkedListAtom(thing): thing is LinkedListLikeAtom<LinkedList<LLNode<Rec>>>

Defined in: primitives/reatomLinkedList.ts:740

Parameters

thing

any

Returns

thing is LinkedListLikeAtom<LinkedList<LLNode<Rec>>>


reatomArray()

reatomArray<T>(initState, name): ArrayAtom<T>

Defined in: primitives/reatomArray.ts:11

Type Parameters

T

T

Parameters

initState

T[] = ...

name

string = ...

Returns

ArrayAtom<T>


reatomBoolean()

reatomBoolean(init, name): BooleanAtom

Defined in: primitives/reatomBoolean.ts:11

Parameters

init

boolean = false

name

string = ...

Returns

BooleanAtom


reatomEnum()

reatomEnum<T, Format>(variants, options): EnumAtom<T, Format>

Defined in: primitives/reatomEnum.ts:33

Type Parameters

T

T extends string

Format

Format extends "camelCase" | "snake_case" = "camelCase"

Parameters

variants

readonly T[]

options

string | EnumAtomOptions<T, Format>

Returns

EnumAtom<T, Format>


reatomLinkedList()

Call Signature

reatomLinkedList<Node, Params, Key>(initState, name?): LinkedListAtom<Params, Node, Key>

Defined in: primitives/reatomLinkedList.ts:252

Type Parameters
Node

Node extends Rec

Params

Params extends any[] = [Node]

Key

Key extends string | number | symbol = never

Parameters
initState

Node[]

name?

string

Returns

LinkedListAtom<Params, Node, Key>

Call Signature

reatomLinkedList<Params, Node, Key>(initState, name?): LinkedListAtom<Params, Node, Key>

Defined in: primitives/reatomLinkedList.ts:258

Type Parameters
Params

Params extends any[]

Node

Node extends Rec

Key

Key extends string | number | symbol = never

Parameters
initState

(…params) => Node

name?

string

Returns

LinkedListAtom<Params, Node, Key>

Call Signature

reatomLinkedList<Params, Node, Key>(initState, name?): LinkedListAtom<Params, Node, Key>

Defined in: primitives/reatomLinkedList.ts:267

Type Parameters
Params

Params extends any[]

Node

Node extends Rec

Key

Key extends string | number | symbol = never

Parameters
initState
create

(…params) => Node

initState?

Node[]

key?

Key

name?

string

Returns

LinkedListAtom<Params, Node, Key>

Call Signature

reatomLinkedList<Params, Node, Key>(initState, name?): LinkedListAtom<Params, Node, Key>

Defined in: primitives/reatomLinkedList.ts:280

Type Parameters
Params

Params extends any[]

Node

Node extends Rec

Key

Key extends string | number | symbol = never

Parameters
initState
create?

(…params) => Node

initState

Node[]

key?

Key

name?

string

Returns

LinkedListAtom<Params, Node, Key>

Call Signature

reatomLinkedList<Params, Node, Key>(initSnapshot, name?): LinkedListAtom<Params, Node, Key>

Defined in: primitives/reatomLinkedList.ts:293

Type Parameters
Params

Params extends any[]

Node

Node extends Rec

Key

Key extends string | number | symbol = never

Parameters
initSnapshot
create

(…params) => Node

initSnapshot?

Params[]

key?

Key

name?

string

Returns

LinkedListAtom<Params, Node, Key>


reatomMap()

reatomMap<Key, Value>(initState, name): MapAtom<Key, Value>

Defined in: primitives/reatomMap.ts:41

Type Parameters

Key

Key

Value

Value

Parameters

initState

StateInit<Key, Value> = ...

name

string = ...

Returns

MapAtom<Key, Value>


reatomNumber()

reatomNumber(initState, name): NumberAtom

Defined in: primitives/reatomNumber.ts:12

Parameters

initState

number = 0

name

string = ...

Returns

NumberAtom


reatomRecord()

reatomRecord<T>(initState, name): RecordAtom<T>

Defined in: primitives/reatomRecord.ts:12

Type Parameters

T

T extends Rec

Parameters

initState

Exclude<T, Fn>

name

string = ...

Returns

RecordAtom<T>


reatomSet()

reatomSet<T>(initState, name): SetAtom<T>

Defined in: primitives/reatomSet.ts:17

Type Parameters

T

T

Parameters

initState

StateInit<T> = ...

name

string = ...

Returns

SetAtom<T>