Themes

Stores/Utils/createCorrelationStore
createCorrelationStore

Create a new correlation store with a sorting function.

(sortingFunction: SortingFunction<T> correlateBy?: keyofT ) => CorrelationStore<T>

CorrelationStore

A store for holding a list of objects, correlated by a key.

Name
Description
Type
[iterator]
() => [string, string[]][]
delete
(id: string ) => boolean
firstItem
(id: string ) => undefined | T
get
(id: string ) => undefined | string[]
getHead
(id: string ) => undefined | string
getSize
(id: string ) => undefined | number
getTail
(id: string truncate: number ) => undefined | string[]
has
(id: string ) => boolean
insert
(item: T ) => void
invalidateMemos
() => void
items

Access to the backing ListStore

ListStore<T>
keys
() => string[]
memo
(fn: (store: CorrelationStore<T> ) => R ) => () => R
memoFilteredKeys
(fn: (item: T ) => boolean sort: (a: T b: T ) => number ) => () => string[]
memoReduce
(fn: (acc: R item: T id: string store: CorrelationStore<T> ) => R initial: R ) => () => R
memoSome
(fn: (item: T id: string store: CorrelationStore<T> ) => boolean ) => () => boolean
size

Current number of items in the store.

number
state

The internal state of the store.

Record<string, string[]>
values
() => string[][]

ListStore

A store for holding a list of objects.

Name
Description
Type
[$data]

internal access to data

Readonly<Map<string, T>>
[iterator]
() => [string, T][]
delete
(id: string ) => boolean
entries
() => [string, T][]
extract
(ids: string[]filterMap: (item: T i: number ) => null | R ) => R[]
get
(id: string ) => undefined | T
getOrInsert
(id: string defaultValue: () => T ) => T
has
(id: string ) => boolean
keys
() => string[]
on

subscribe to events within the store

OnHandler<Record<string, T>>
reset
() => void
set
(id: string item: T ) => void
size

Current number of items in the store.

number
state

The internal state of the store.

Record<string, T>
update
(id: string updater: (item: T ) => T ) => boolean
updateOrSet
(id: string updater: (item: T ) => T creator: () => T ) => boolean
updateWhenAvailable
(id: string updater: (item: T ) => T maxWait: number ) => Promise<boolean>
values
() => T[]
dispose

Resets the state to its original state and signals a dispose event to all the plugins.

() => void
onChange

Listen to a change on a single item in the store.

(id: string cb: (item: T ) => void ) => () => void
onChange

Listen to a change on the entire store.

(cb: (list: Record<string, T> ) => void ) => () => void
use

Registers a subscription that will be called whenever the user gets, sets, or resets a value.

(plugins: Plugin<Record<string, T>>[]) => () => void

Plugin

Plugin<T extends any> = (store: Store<T> ) => Subscription<T>