Options
Menu

Interface UnitConfig<T>

Configuration options for all the Units.

Hierarchy

Common Properties

Optional replay

replay: boolean

A flag to control the replay behaviour of a Unit. It decides whether the value should be replayed when you subscribe to the default Observable.

default

true

Other Properties

Optional id

id: string

A unique id to identify a Unit. It's required for a Unit to be persistent.

default

undefined

Units Properties

Optional cacheSize

cacheSize: number

Optional config option to set the cache size. It can be minimum 1, and maximum Infinity. Otherwise, if it's not provided, or it's not valid, the default cache size 2 will be used.

default

2

Optional customDispatchCheck

customDispatchCheck: (currentValue: T, nextValue: T) => boolean

An optional custom check function, if provided, can allow or disallow values from getting through dispatch.

default

undefined

Type declaration

    • (currentValue: T, nextValue: T): boolean
    • Parameters

      • currentValue: T
      • nextValue: T

      Returns boolean

Optional dispatchDebounce

dispatchDebounce: boolean | number

Set it to true to debounce the dispatch method. If set it to true the default wait-time is 200ms, otherwise you can pass a number as wait-time, which is in ms.

default

false

Optional dispatchDebounceMode

dispatchDebounceMode: "START" | "END" | "BOTH"

If the dispatchDebounce is enabled, the debounce mode determines on which edge of the wait-time, the call passes through. In a debounce wait-time span, START means only the first call to dispatch gets through. END means only the last call to dispatch gets through. BOTH means both, the first and last dispatch calls get through. The default is END.

default

END

Optional distinctDispatchCheck

distinctDispatchCheck: boolean

An optional flag to disable/enable the distinct value check on the dispatched values.

default

false

Optional immutable

immutable: boolean

An optional flag to make the Unit's value immutable.

default

false

Optional initialValue

initialValue: T

The initial value for the Unit to be used instead of the default value. Type T is the type of the Unit's value. i.e. boolean for BoolUnit. If an initialValue is not provided or if its invalid, it'll be ignored, and the default value of the Unit will be used instead.

default

BoolUnit: false
NumUnit: 0
StringUnit: ''
ListUnit: []
DictUnit: {}
GenericUnit: undefined

Optional persistent

persistent: boolean

An optional flag to make the Unit persistent, using LocalStorage or SessionStorage. An id (see BaseConfig.id) is mandatory to make it work.

default

false

Optional storage

storage: Storage

The Storage to be used for storing the value if the Unit is persistent.
It can be either LocalStorage or SessionStorage or any other API, that implements Storage API interface.

default

Configuration.storage