@epikodelabs/streamix / src/public-api / derived
Function: derived()
Call Signature
derived<
T>(fn,options?):Atom<T>
Defined in: projects/libraries/streamix/src/lib/atoms/atom.ts:1529
Creates a readonly atom computed from other atoms.
Dependencies are tracked when the callback reads atoms through self.read, self.use, or the callable shorthand self(atom).
Async callbacks only track atoms read before the first await. Capture dependencies up front with self.use(...) / self.read(...), or use flow() when the computation is primarily async and cancellation-aware.
Type Parameters
T
T
Parameters
fn
(self) => SyncOnly<T>
options?
Returns
Atom<T>
Call Signature
derived<
T>(fn,options?):Atom<T>
Defined in: projects/libraries/streamix/src/lib/atoms/atom.ts:1535
Creates a readonly atom from an async computation.
Dependencies must be read before the first await to be tracked.
Type Parameters
T
T
Parameters
fn
(self) => Promise<T>
options?
Returns
Atom<T>
Call Signature
derived<
T>(fn,options?):Atom<T>
Defined in: projects/libraries/streamix/src/lib/atoms/atom.ts:1541
Creates a readonly atom from a generator-based computation.
The generator may yield atoms or promises before returning the computed value.
Type Parameters
T
T
Parameters
fn
(self) => Generator<Promise<any> | Atom<any>, T, any>
options?
Returns
Atom<T>