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.


  • CalculationCache



  • Manually invalidates the cached outcome.

    Returns void

  • 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 ===.


    • inputs: unknown[]

      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: (() => Result)

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

        • (): Result
        • Returns Result

    Returns Result

Generated using TypeDoc