Skip to content

FormulaFnoptimization

T

The value computed by the formula.

Constructor Function

function FormulaFn(fn, description?): FormulaFn;

A FormulaFn is a function that automatically caches the result of its computation until any of its reactive dependencies change.

fn() => T

A function that computes a value from other reactive values.

description?string

A description of the formula.

optional

returnsFormulaFn

A formula that returns the result of the given function.

Properties

current

readonly current: T;

The current value of the formula.

PolledFormulaFnrenderer

T

The value computed by the formula.

Constructor Function

function PolledFormulaFn(fn, description?): PolledFormulaFn;

A PolledFormulaFn has an identical API signature to FormulaFn. However, when a PolledFormulaFn’s value is requested, it always recomputes the value. This is designed for situations where you are mixing Starbeam reactivity with other forms of reactivity.

fn() => T

A function that computes a value from other reactive values.

description?string

A description of the formula.

optional

returnsPolledFormulaFn

A polled formula that returns the result of the given function.

Details: Using PolledFormulaFn in Renderers

This allows a renderer to listen for changes to the formula’s reactive dependencies, but still choose to recompute the formula’s value when it has its own reason to believe that the formula is out of date. Most renderers use PolledFormulaFn as the primary mechanism for gluing Starbeam reactivity with their framework’s rendering.

Properties

current

readonly current: T;

The current value of the formula.

Released under the MIT license