Function createCachedResource

  • Create a cached resource

    const [user, { refetch, mutate }] = createCachedResource(() => ["user", props.id], async ([, userId]) => {
    // ...fetch data
    });

    Description

    https://yonathan06.github.io/solid-cached-resource/modules.html#createCachedResource

    Type Parameters

    • T

    • S = any

    Parameters

    • source: ResourceSource<S>

      reactive data function to toggle the request - key is derived for the value (parsed to string)

    • fetcher: ResourceFetcher<S, T>

      function that receives the source (or true) and an accessor for the last or initial value and returns a value or a Promise with the value

    • Optional options: CachedResourceOptions<T>

      optional object with the initialValue and refetchOnMount flag (defaults to true)

    Returns ResourceReturn<undefined | T, undefined | { deferStream?: boolean; initialValue?: undefined; name?: string; onHydrated?: (<S, T>(k: S, info: ResourceFetcherInfo<T>) => void) }, undefined | T>

Generated using TypeDoc