Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "defonce"

Index

Variables

Functions

Variables

Const cache

cache: any

Functions

Const defonce

  • defonce<T>(id: string, factory: Fn0<T>): T
  • Lightweight named singleton factory, intended for hot-module replacement situations. Takes a (preferably globally unique) id and factory function. If there's no value defined for id yet, calls factory to produce the singleton value and caches it. Returns singleton value.

    Note: All created values will remain in the private cache until the JS process terminates or this module itself has been reloaded (though the latter shouldn't happen in an HMR workflow).

    Type parameters

    • T

    Parameters

    • id: string
    • factory: Fn0<T>

    Returns T

Generated using TypeDoc