Skip to content

Interface: Readable<T>

API / @xmachines/play-atom / Readable

Defined in: types.ts:58

The read side of an atom

Readable holds get() and subscribe(). A function that only READS an atom takes this type, and it therefore accepts an Atom, a ReadonlyAtom, and a store selection alike.

Example

import { createAtom, type Readable } from "@xmachines/play-atom";
function show(source: Readable<string>): string {
return source.get();
}
show(createAtom("ready")); // "ready"

Extended by

Type Parameters

Type Parameter
T

Methods

get()

get(): T;

Defined in: types.ts:59

Returns

T


subscribe()

Call Signature

subscribe(observer): AtomSubscription;

Defined in: types.ts:60

Parameters
ParameterType
observerAtomObserver<T>
Returns

AtomSubscription

Call Signature

subscribe(
next,
error?,
complete?
): AtomSubscription;

Defined in: types.ts:61

Parameters
ParameterType
next(value) => void
error?(error) => void
complete?() => void
Returns

AtomSubscription