optimism

  • Version 0.16.1
  • Published
  • 124 kB
  • 2 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[]) => any;

    function dep

    dep: <TKey>(options?: {
    subscribe: Dep<TKey>['subscribe'];
    }) => OptimisticDependencyFunction<TKey>;

      function wrap

      wrap: <
      TArgs extends any[],
      TResult,
      TKeyArgs extends any[] = TArgs,
      TCacheKey = any
      >(
      originalFunction: (...args: TArgs) => TResult,
      options?: 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;
            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 (2)

              Dependencies (2)

              Dev Dependencies (11)

              Peer Dependencies (0)

              No peer dependencies.

              Badge

              To add a badge like this onejsDocs.io badgeto 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>