Skip to content

@continuum-js/frp


@continuum-js/frp / State

Class: State<A>

Defined in: index.ts:963

A value across time (pull) with discrete change notifications (push). Denotationally Time → A: it always has a value — sample() never misses.

Extended by

Type Parameters

A

A

Constructors

Constructor

new State<A>(sampleNoTrans, updates): State<A>

Defined in: index.ts:964

Parameters

sampleNoTrans

() => A

Pull the current value without opening a transaction.

updates

Stream<A>

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

Returns

State<A>

Properties

sampleNoTrans

sampleNoTrans: () => A

Defined in: index.ts:966

Pull the current value without opening a transaction.

Returns

A


updates

updates: Stream<A>

Defined in: index.ts:968

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

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>

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>


dispose()

dispose(): void

Defined in: index.ts:1016

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

Returns

void


listen()

listen(h): Unlisten

Defined in: index.ts:999

Deliver the current value immediately, then every change.

Parameters

h

(a) => void

Returns

Unlisten


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>


retain()

retain(): this

Defined in: index.ts:1021

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

Returns

this


sample()

sample(): A

Defined in: index.ts:971

Returns

A


fromPoll()

static fromPoll<A>(poll): State<A>

Defined in: index.ts:1031

Continuous behavior: sampled fresh on each read; no discrete updates.

Type Parameters

A

A

Parameters

poll

() => A

Returns

State<A>