createDeferred
Creates an async memo that may lag, but never leads: after its first
answer, a refetch holds nothing — readers keep the previous answer until
the new one lands, and isPending reports the refetch. See
createDeferred in @solidjs/signals. Hydrates like createMemo: the
server's answer is its first.
Import
import { createDeferred } from "solid-js";Type signature
function createDeferred<T>( compute: ComputeFunction<NoInfer<T>, T>, options: MemoOptions<T> & { loadingValue: T }): SourceAccessor<T>;function createDeferred<T>( compute: ComputeFunction<undefined | NoInfer<T>, T>, options?: MemoOptions<T>): SourceAccessor<T>;Parameters
compute
- Type:
ComputeFunction<NoInfer<T>, T> | ComputeFunction<undefined | NoInfer<T>, T>
options
- Type:
MemoOptions<T> & { loadingValue: T } | MemoOptions<T> - Optional
Examples
const rows = createDeferred(() => fetchRows(store.period));
<section class={{ stale: isPending(() => rows()) }}> <For each={rows()}>{(row) => <Row row={row} />}</For></section>;