Skip to content

@continuum-js/frp


@continuum-js/frp / StateSource

Interface: StateSource<A>

Defined in: index.ts:1404

A source state: a cell you read like any state and write via .set.

Extends

Type Parameters

A

A

Properties

sampleNoTrans

sampleNoTrans: () => A

Defined in: index.ts:966

Pull the current value without opening a transaction.

Returns

A

Inherited from

State.sampleNoTrans


updates

updates: Stream<A>

Defined in: index.ts:968

Push notifications of discrete changes (empty for continuous behaviors).

Inherited from

State.updates

Methods

at()

Call Signature

at<B>(e): Stream<A>

Defined in: index.ts:988

Sample this state at each occurrence of e: draft.at(submits) is the stream of the state's values as of those moments (pre-moment, with exact simultaneity semantics). An optional combiner receives (value, event).

Type Parameters
B

B

Parameters
e

Stream<B>

Returns

Stream<A>

Inherited from

State.at

Call Signature

at<B, C>(e, f): Stream<C>

Defined in: index.ts:989

Sample this state at each occurrence of e: draft.at(submits) is the stream of the state's values as of those moments (pre-moment, with exact simultaneity semantics). An optional combiner receives (value, event).

Type Parameters
B

B

C

C

Parameters
e

Stream<B>

f

(value, event) => C

Returns

Stream<C>

Inherited from

State.at


dispose()

dispose(): void

Defined in: index.ts:1016

Detach this behavior's updates from the graph (see Stream.dispose).

Returns

void

Inherited from

State.dispose


listen()

listen(h): Unlisten

Defined in: index.ts:999

Deliver the current value immediately, then every change.

Parameters

h

(a) => void

Returns

Unlisten

Inherited from

State.listen


map()

map<B>(f): State<B>

Defined in: index.ts:979

Pointwise transform (continuous-safe: recomputed on each sample).

Type Parameters

B

B

Parameters

f

(a) => B

Returns

State<B>

Inherited from

State.map


on()

on<E>(e, f): this

Defined in: index.ts:1422

Declare a state transition: on each occurrence of e, fold the reducer over the current value — (state, event) => next, useReducer order. The occurrence and the state's update share ONE moment (snapshot semantics hold), and several .on sources firing simultaneously fold sequentially. The transition process belongs to the ambient scope.

Type Parameters

E

E

Parameters

e

Stream<E>

f

(state, event) => A

Returns

this


retain()

retain(): this

Defined in: index.ts:1021

Keep this behavior's update chain alive across listener churn (see Stream.retain).

Returns

this

Inherited from

State.retain


sample()

sample(): A

Defined in: index.ts:971

Returns

A

Inherited from

State.sample


set()

set(a): void

Defined in: index.ts:1406

Set the current value; equal values (by the cell's eq) are a no-op.

Parameters

a

A

Returns

void


update()

update(f): void

Defined in: index.ts:1414

Read-modify-write: fold the updater over the current value — count.update((n) => n + 1). Inside a batch the updater sees the value staged by this very moment, so several updates compose (unlike set(sample() + 1), which reads the pre-moment value). Equal results (by the cell's eq) are a no-op.

Parameters

f

(state) => A

Returns

void