Skip to main content

Class: Reducer<T, A>

Type parameters

Name
T
A

Constructors

constructor

new Reducer<T, A>(opts)

Type parameters

Name
T
A

Parameters

NameTypeDescription
optsObject-
opts.callback(state: T) => voidA callback function called when the state changes, either because of a local call to dispatch or a remote event.
opts.dbDbConnectionThe database connection to use.
opts.initialValueTThe initial state passed to the reducer.
opts.keystringA key identifying the stream to use for the reducer.
opts.reducer(state: T, action: A) => TThe reducer function applied when dispatch is called.
opts.sizeThreshold?numberThe number of messages to keep in the stream before compacting.

Defined in

js-pkg/packages/driftdb/src/reducer.ts:23

Properties

compactor

compactor: Compactor<T, A>

Defined in

js-pkg/packages/driftdb/src/reducer.ts:21

Methods

destroy

destroy(): void

Returns

void

Defined in

js-pkg/packages/driftdb/src/reducer.ts:58


dispatch

dispatch(action): void

Parameters

NameType
actionA

Returns

void

Defined in

js-pkg/packages/driftdb/src/reducer.ts:62


subscribe

subscribe(): void

Returns

void

Defined in

js-pkg/packages/driftdb/src/reducer.ts:54