Themes

Stores/Utils/createListStore
createListStore

Create a new list store with the given initial state.

(initialState?: Record<string, T> = {}) => ListStore<T>

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>