Skip to content

LoadState type

Home > @rimitive/view > LoadState

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

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()!);
}
})
)