import { Fn } from '@solidjs-use/shared'; import { Setter, Accessor } from 'solid-js'; /** * Handle overlapping async evaluations. * * @param cancelCallback The provided callback is invoked when a re-evaluation of the computed value is triggered before the previous one finished */ type AsyncComputedOnCancel = (cancelCallback: Fn) => void; interface AsyncComputedOptions { /** * Ref passed to receive the updated of async evaluation */ setEvaluating?: Setter; /** * Callback when error is caught. */ onError?: (e: unknown) => void; } /** * Create an asynchronous computed dependency. * * @see https://solidjs-use.github.io/solidjs-use/core/createAsyncMemo * @param evaluationCallback The promise-returning callback which generates the computed value * @param initialState The initial state, used until the first evaluation finishes * @param optionsOrSignal Additional options or a Signal passed to receive the updates of the async evaluation */ declare function createAsyncMemo(evaluationCallback: (onCancel: AsyncComputedOnCancel) => T | Promise, initialState?: T, optionsOrSetter?: Setter | AsyncComputedOptions): Accessor; export { AsyncComputedOnCancel, AsyncComputedOptions, createAsyncMemo as asyncMemo, createAsyncMemo };