Skip to content

@epikodelabs/streamix


@epikodelabs/streamix / src/public-api / Atom

Interface: Atom<T>

Defined in: projects/libraries/streamix/src/lib/atoms/atom.ts:91

Readable reactive value.

Atoms expose the current value synchronously through value, can be subscribed to, and are also async iterable for for await...of consumers.

Extended by

Type Parameters

T

T = any

Properties

type

readonly type: "atom"

Defined in: projects/libraries/streamix/src/lib/atoms/atom.ts:93

Runtime discriminator for atom-like values.


name?

readonly optional name: string

Defined in: projects/libraries/streamix/src/lib/atoms/atom.ts:95

Optional human-readable name used by integrations and diagnostics.


value

readonly value: T

Defined in: projects/libraries/streamix/src/lib/atoms/atom.ts:97

Current value. Throws if the atom is currently in an error state.


safeValue

readonly safeValue: T

Defined in: projects/libraries/streamix/src/lib/atoms/atom.ts:99

Current value, returning the last safe value when the atom has errored.


previous

readonly previous: T

Defined in: projects/libraries/streamix/src/lib/atoms/atom.ts:101

Previously emitted value.


disposed

readonly disposed: boolean

Defined in: projects/libraries/streamix/src/lib/atoms/atom.ts:103

True after the atom has been disposed.


dirty

readonly dirty: boolean

Defined in: projects/libraries/streamix/src/lib/atoms/atom.ts:105

True when an analog update is queued but not flushed yet.


error?

readonly optional error: any

Defined in: projects/libraries/streamix/src/lib/atoms/atom.ts:107

Last error captured by this atom, if any.


subscriberCount?

readonly optional subscriberCount: number

Defined in: projects/libraries/streamix/src/lib/atoms/atom.ts:109

Number of active subscribers, when exposed by the implementation.

Methods

subscribe()

subscribe(callback?): Subscription

Defined in: projects/libraries/streamix/src/lib/atoms/atom.ts:116

Subscribes to value changes.

The callback receives (current, previous). The returned subscription must be disposed when the listener is no longer needed.

Parameters

callback?

(current, previous) => any

Returns

Subscription


onError()

onError(handler): Subscription

Defined in: projects/libraries/streamix/src/lib/atoms/atom.ts:118

Subscribes to atom errors.

Parameters

handler

(error) => void

Returns

Subscription


dispose()

dispose(): void

Defined in: projects/libraries/streamix/src/lib/atoms/atom.ts:120

Stops the atom and releases all subscribers/resources.

Returns

void


[asyncIterator]()

[asyncIterator](): AsyncIterator<T>

Defined in: projects/libraries/streamix/src/lib/atoms/atom.ts:122

Iterates emitted values until the atom is disposed or iteration is closed.

Returns

AsyncIterator<T>

Released under the GNU AGPL v3 or later.