AsyncCollectionLoaderT
import { type AsyncCollectionLoaderT } from '@dr.pogodin/react-global-state';
The AsyncCollectionLoaderT type is the signature of a valid data loader function for the useAsyncCollection() hook.
It is defined as a generic type:
type AsyncCollectionLoaderT<DataT> =
(id: string, oldData: null | DataT) => DataT | Promise<DataT>
Generic Parameters
Arguments
The data loader function receives two arguments:
id
— string — The identifier of collection item to load.oldData
— DataT | null — The item previously loaded for thisid
, if any; or null.
Result
The data loader function must either return a Promise resolving to a DataT value for the given ID, or just return the DataT value directly.