optimism
- Version 0.18.1
- Published
- 187 kB
- 4 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, keyArgs, makeCacheKey, normalizeResult, subscribe, cache: cacheOption, }?: OptimisticWrapOptions<TArgs, TKeyArgs, TCacheKey, TResult>) => OptimisticWrapperFunction<TArgs, TResult, TKeyArgs, TCacheKey>;
Interfaces
interface CommonCacheConstructor
interface CommonCacheConstructor<TCacheKey, TResult, TArgs extends any[]> extends Function {}
construct signature
new <K extends TCacheKey, V extends Entry<TArgs, TResult>>( max?: number, dispose?: (value: V, key?: K) => void): CommonCache<K, V>;
interface OptionsWithCacheInstance
interface OptionsWithCacheInstance< TArgs extends any[], TKeyArgs extends any[] = TArgs, TCacheKey = any, TResult = any> extends OptimisticWrapOptions<TArgs, TKeyArgs, TCacheKey, TResult> {}
property cache
cache: CommonCache<NoInfer<TCacheKey>, Entry<NoInfer<TArgs>, NoInfer<TResult>>>;
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, TResult = any> = { max?: number; keyArgs?: (...args: TArgs) => TKeyArgs; makeCacheKey?: (...args: NoInfer<TKeyArgs>) => TCacheKey | undefined; normalizeResult?: (newer: TResult, older: TResult) => TResult; subscribe?: (...args: TArgs) => void | (() => any); cache?: | CommonCache<NoInfer<TCacheKey>, Entry<NoInfer<TArgs>, NoInfer<TResult>>> | CommonCacheConstructor< NoInfer<TCacheKey>, NoInfer<TResult>, NoInfer<TArgs> >;};
type OptimisticWrapperFunction
type OptimisticWrapperFunction< TArgs extends any[], TResult, TKeyArgs extends any[] = TArgs, TCacheKey = any> = ((...args: TArgs) => TResult) & { readonly size: number; options: OptionsWithCacheInstance<TArgs, TKeyArgs, TCacheKey>; dirty: (...args: TKeyArgs) => void; dirtyKey: (key: TCacheKey | undefined) => void; peek: (...args: TKeyArgs) => TResult | undefined; peekKey: (key: TCacheKey | undefined) => TResult | undefined; forget: (...args: TKeyArgs) => boolean; forgetKey: (key: TCacheKey | undefined) => boolean; getKey: (...args: TArgs) => TCacheKey | undefined; makeCacheKey: (...args: TKeyArgs) => TCacheKey | undefined;};
Package Files (3)
Dependencies (4)
Dev Dependencies (8)
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 3172 ms. - Missing or incorrect documentation? Open an issue for this package.