optimism
- Version 0.17.5
- Published
- 187 kB
- 3 dependencies
- MIT license
Install
npm i optimism
yarn add optimism
pnpm add optimism
Overview
Composable reactive caching with efficient invalidation.
Index
Functions
function defaultMakeCacheKey
defaultMakeCacheKey: (...args: any[]) => object;
function dep
dep: <TKey>(options?: { subscribe: Dep<TKey>['subscribe'];}) => OptimisticDependencyFunction<TKey>;
function nonReactive
nonReactive: <R>(fn: () => R) => R;
function wrap
wrap: < TArgs extends any[], TResult, TKeyArgs extends any[] = TArgs, TCacheKey = any>( originalFunction: (...args: TArgs) => TResult, { max, makeCacheKey, keyArgs, subscribe, }?: OptimisticWrapOptions<TArgs, TKeyArgs>) => OptimisticWrapperFunction<TArgs, TResult, TKeyArgs, TCacheKey>;
Type Aliases
type OptimisticDependencyFunction
type OptimisticDependencyFunction<TKey> = ((key: TKey) => void) & { dirty: (key: TKey, entryMethodName?: EntryMethodName) => void;};
type OptimisticWrapOptions
type OptimisticWrapOptions< TArgs extends any[], TKeyArgs extends any[] = TArgs, TCacheKey = any> = { max?: number; keyArgs?: (...args: TArgs) => TKeyArgs; makeCacheKey?: (...args: TKeyArgs) => TCacheKey; subscribe?: (...args: TArgs) => void | (() => any);};
type OptimisticWrapperFunction
type OptimisticWrapperFunction< TArgs extends any[], TResult, TKeyArgs extends any[] = TArgs, TCacheKey = any> = ((...args: TArgs) => TResult) & { readonly size: number; options: OptimisticWrapOptions<TArgs, TKeyArgs, TCacheKey>; dirty: (...args: TKeyArgs) => void; dirtyKey: (key: TCacheKey) => void; peek: (...args: TKeyArgs) => TResult | undefined; peekKey: (key: TCacheKey) => TResult | undefined; forget: (...args: TKeyArgs) => boolean; forgetKey: (key: TCacheKey) => boolean; getKey: (...args: TArgs) => TCacheKey; makeCacheKey: (...args: TKeyArgs) => TCacheKey;};
Package Files (3)
Dependencies (3)
Dev Dependencies (7)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/optimism
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/optimism)
- HTML<a href="https://www.jsdocs.io/package/optimism"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2938 ms. - Missing or incorrect documentation? Open an issue for this package.