Skip to main content

Class: StateListener<T>

Provides a way to store a single value on a key in a DriftDB room, and listen for changes to that value from other clients.

Type parameters

Name
T

Constructors

constructor

new StateListener<T>(opts)

Type parameters

Name
T

Parameters

NameType
optsObject
opts.callback(value: T) => void
opts.dbDbConnection
opts.debounceMillis?number
opts.keystring

Defined in

js-pkg/packages/driftdb/src/state.ts:25

Properties

callback

callback: (value: T) => void

Type declaration

▸ (value): void

Parameters
NameType
valueT
Returns

void

Defined in

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


db

db: DbConnection

Defined in

js-pkg/packages/driftdb/src/state.ts:22


debounceMillis

debounceMillis: number

Defined in

js-pkg/packages/driftdb/src/state.ts:17


debounceTimeout

debounceTimeout: null | number = null

Defined in

js-pkg/packages/driftdb/src/state.ts:16


handler

handler: (value: SequenceValue) => void

Type declaration

▸ (value): void

Parameters
NameType
valueSequenceValue
Returns

void

Defined in

js-pkg/packages/driftdb/src/state.ts:20


key

key: string

Defined in

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


lastUpdateSent

lastUpdateSent: number = 0

Defined in

js-pkg/packages/driftdb/src/state.ts:14


lastValue

lastValue: null | T = null

Defined in

js-pkg/packages/driftdb/src/state.ts:15


randId

randId: string

Defined in

js-pkg/packages/driftdb/src/state.ts:19


state

state: null | T = null

Defined in

js-pkg/packages/driftdb/src/state.ts:18

Methods

destroy

destroy(): void

Returns

void

Defined in

js-pkg/packages/driftdb/src/state.ts:50


onMessage

onMessage(value): void

Parameters

NameType
valueSequenceValue

Returns

void

Defined in

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


sendUpdate

sendUpdate(): void

Returns

void

Defined in

js-pkg/packages/driftdb/src/state.ts:59


setStateOptimistic

setStateOptimistic(value): void

Parameters

NameType
valueT

Returns

void

Defined in

js-pkg/packages/driftdb/src/state.ts:73


subscribe

subscribe(): void

Returns

void

Defined in

js-pkg/packages/driftdb/src/state.ts:46