LoadState type
Home > @rimitive/view > LoadState
LoadState type
Section titled “LoadState type”Load state object with reactive properties
Signature:
export type LoadState<T> = { readonly status: Reactive<LoadStatus>; readonly data: Reactive<T | undefined>; readonly error: Reactive<unknown | undefined>;};References: Reactive, LoadStatus
Example
Section titled “Example”load( () => fetchData(), (state) => match(state.status, (status) => { switch (status) { case 'pending': return el('div')('Loading...'); case 'error': return el('div')(`Error: ${state.error()}`); case 'ready': return DataView(state.data()!); } }))