Class: ContextMemoization<T>

Create a memoization in context to store the result of a getter function

Type Parameters

T

Implements

  • ContextMemoryOptions

Constructors

new ContextMemoization()

new ContextMemoization<T>(getter, options): ContextMemoization<T>

Parameters

getter

options: Partial<ContextMemoryOptions> = {}

Returns

ContextMemoization<T>

Defined in

packages/core/src/utils/context.ts:111

Properties

getMemoizationMap()

getMemoizationMap: () => undefined | WeakMap<WeakKey, any>

Returns

undefined | WeakMap<WeakKey, any>

Implementation of

ContextMemoryOptions.getMemoizationMap

Defined in

packages/core/src/utils/context.ts:120


getter()

readonly getter: () => T

Returns

T

Defined in

packages/core/src/utils/context.ts:112


key

readonly key: WeakKey

Implementation of

ContextMemoryOptions.key

Defined in

packages/core/src/utils/context.ts:121

Methods

clear()

clear(): undefined | boolean

Clear the memoization

Returns

undefined | boolean

true if the memoization is cleared, undefined if the context is not found

Defined in

packages/core/src/utils/context.ts:142


exists()

exists(): undefined | boolean

Check if the memoization exists

Returns

undefined | boolean

true if the memoization exists, undefined if the context is not found

Defined in

packages/core/src/utils/context.ts:152


get()

get(): T

Get the value in memoization or call the getter function

Returns

T

the value of the getter function

Defined in

packages/core/src/utils/context.ts:127


set()

set(value): undefined | WeakMap<WeakKey, any>

Set a new value to the memoization

Parameters

value: T

the new value to set

Returns

undefined | WeakMap<WeakKey, any>

the memoization map or undefined if the context is not found

Defined in

packages/core/src/utils/context.ts:163


assignMemoizationMap()

static assignMemoizationMap(target): WeakMap<WeakKey, any>

Parameters

target: ContextMemoryContainer

Returns

WeakMap<WeakKey, any>

Defined in

packages/core/src/utils/context.ts:169