Options
All
  • Public
  • Public/Protected
  • All
Menu

react-suspense-cache

Index

Type aliases

Fetcher

Fetcher<T>: (...args: StorageRequest) => Promise<T>

A asynchronous function that receives StorageRequest and resolves to a data

Type parameters

  • T

    type of the data to be resolved.

Type declaration

Key

Key: string

The type of the value to be returned by the KeyFactory.

This key is used to indicate the cache slot for both the resource and the global cache.

KeyFactory

KeyFactory: (...args: StorageRequest) => Key

A function that receives [[Storagerequest]] and returns a Key.

Type declaration

RequestWillFetchParam

RequestWillFetchParam<T>: ResourceHandlerParam<T>

An object to be received by the ResourcePlugin's "requestWillFetch" property.

Type parameters

  • T

    type of the cache data

ResponseData

ResponseData<T>: ResponseFailure | ResponseSuccess<T>

Cache response types

Type parameters

  • T

    type of the resolved value.

StorageRequest

StorageRequest: any[]

An array of values to be received by the KeyFactory and the data fetcher.

Core Functions

createResource

  • createResource<T, Params>(__namedParameters: { cacheName: undefined | string; fetcher: (...args: StorageRequest) => Promise<T>; keyFactory: (...args: StorageRequest) => Key; revalidateOnVisibility: undefined | false | true; strategy: undefined | ResourceHandler<T>; updateOnVisibility: undefined | false | true }): Resource<T, Params>

Other Functions

cacheData

fetchData

matchData

Object literals

Const RESOURCE_CACHE

RESOURCE_CACHE: object

delete

  • delete(cacheName: string, key: Key): void

get

  • get<T>(cacheName: string, key: Key): ResourceCache<T> | undefined

has

  • has(cacheName: string, key: Key): boolean

set

  • set<T>(cacheName: string, key: Key, value: ResourceCache<T>): void

Const STRATEGY_CACHE

STRATEGY_CACHE: object

get

  • Gets the cached data from the given cache and key

    Type parameters

    • T

      the type of the cached value

    Parameters

    • cacheName: string

      the name of the cache to access to

    • key: Key

      key of the data to check for

    Returns ResponseData<T> | undefined

has

  • has(cacheName: string, key: Key): boolean
  • Checks if the GlobalCache has the given key of cache occupied

    Parameters

    • cacheName: string

      the name of the cache to access to

    • key: Key

      key of the data to check for

    Returns boolean

set

  • Sets the data to be cached for the given cache and key

    Type parameters

    • T

      the type of the value to be cached with.

    Parameters

    • cacheName: string

      the name of the cache to access to

    • key: Key

      key of the data to check for

    • value: ResponseData<T>

      value to be cached

    Returns void

Generated using TypeDoc