UI kit reference
hooks/keyed-store
import { … } from 'zidane-ui'ui/src/hooks/keyed-store.ts
Functions#
createKeyedStoreFunction#
A new empty KeyedStore.
function createKeyedStore<V>(): KeyedStore<V>Type parameters
| Name | Description |
|---|---|
| V |
Returns
KeyedStore<V>useKeyedValueFunction#
The value under key (null when unset or no key), re-rendering only when that key changes.
function useKeyedValue<V>(
store: KeyedStore<V>,
key: string | null | undefined,
): V | nullType parameters
| Name | Description |
|---|---|
| V |
Parameters
| Name | Type | Description |
|---|---|---|
| store | KeyedStore<V> | The store to read. |
| key | string | null | undefined | The key; |
Returns
V | nullInterfaces#
KeyedStoreInterface#
Values by key, each key with its own subscribers.
interface KeyedStore<V>Type parameters
| Name | Description |
|---|---|
| V |
Properties
| Name | Type | Description |
|---|---|---|
| delete | (key: string) => void | Forget |
| get | (key: string) => V | undefined | The value under |
| set | (key: string, value: V) => void | Store |
| subscribe | (key: string, listener: () => void) => () => void | Call |