Chok’s React Utilities
    Preparing search index...

    Type Alias SharedQueryOptions<TArgs, TData>

    SharedQueryOptions: {
        expiryMs?: number;
        keepLastNonEmptyData?: boolean;
        log?: (...args: unknown[]) => void;
        maxBytes?: number;
        maxSize?: number;
        persistTo?: PersistTo;
        queryFn: QueryFn<TArgs, TData>;
        queryName: string;
        refetchOnStale?: boolean;
        staleMs?: number;
    } & SharedStateOptions<SharedQueryState<TData>>

    Options to configure a shared query.

    Type Parameters

    • TArgs extends unknown[]
    • TData

    Type Declaration

    • OptionalexpiryMs?: number

      ms before data is removed from cache; 0 means never expire.

    • OptionalkeepLastNonEmptyData?: boolean

      Keep a copy of the last non-empty data so that when you change the query arguments, you can still display the old data while waiting for the new data to load.

    • Optionallog?: (...args: unknown[]) => void

      Customize the logger.

    • OptionalmaxBytes?: number

      Max number of bytes to keep. The oldest entries will be discarded. The last record cannot be discarded. 0 means no limit.

    • OptionalmaxSize?: number

      Max number of entries to keep. The oldest entries will be discarded. The last record cannot be discarded. 0 means no limit.

    • OptionalpersistTo?: PersistTo

      Shortcut to set the localStorageKey or indexedDbKey automatically from queryName. This is important because it avoids requiring the user to specify the same queryName twice everytime.

    • queryFn: QueryFn<TArgs, TData>

      Function to fetch data.

    • queryName: string

      The name could have been auto-generated, but we let the user give us a human-readable name that can be identified quickly in the logs. Note that the queryKey is a string formed by the queryName plus the query arguments.

    • OptionalrefetchOnStale?: boolean

      Trigger background re-fetch if stale.

    • OptionalstaleMs?: number

      ms before data considered stale; 0 means always stale.