Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface CalculationCache<Result>

A CalculationCache object remembers the previous outcome of a calculation along with the inputs. On subsequent calls the previous outcome is returned if the inputs are identical. This object can be used to bypass both rendering and diffing of a virtual DOM subtree. Instances of CalculationCache can be created using createCache.

Type parameters

  • Result

    The type of the value that is cached.

Hierarchy

  • CalculationCache

Index

Methods

Methods

invalidate

  • invalidate(): void
  • Manually invalidates the cached outcome.

    Returns void

result

  • result(inputs: Object[], calculation: function): Result
  • If the inputs array matches the inputs array from the previous invocation, this method returns the result of the previous invocation. Otherwise, the calculation function is invoked and its result is cached and returned. Objects in the inputs array are compared using ===.

    Parameters

    • inputs: Object[]

      Array of objects that are to be compared using === with the inputs from the previous invocation. These objects are assumed to be immutable primitive values.

    • calculation: function

      Function that takes zero arguments and returns an object (A VNode presumably) that can be cached.

        • (): Result
        • Returns Result

    Returns Result

Generated using TypeDoc