Concrete implementations of Var implement observe.
Concrete implementations of Var implement observe. This is called for each toplevel observe. Depths indicate the relative structural depth of the observation, from the frame of reference of the root call to observe. (Each Var derived via flatMap increases the depth.) Depths are used to order the invocation of update callbacks. This is used to ensure that updates proceed in topological order so that every input variable is fully resolved before recomputing a derived variable.
Extract the current value of the Var
Create a dependent Var which behaves as f
applied to the
current value of this Var.
Create a dependent Var which behaves as f
applied to the
current value of this Var. FlatMap manages a dynamic dependency
graph: the dependent Var is detached and recomputed whenever
the outer Var changes.
Synonymous with observe
Create a derived variable by applying f
to the contained
value.
Observe this Var.
Observe this Var. f
is invoked each time the variable changes.
Trait Var represents a variable. It is a reference cell which is composable: dependent Vars (derived through flatMap) are recomputed automatically when independent variables change -- they implement a form of self-adjusting computation.
Vars may also be observed, notifying users whenever the variable changes.
There are no well-defined error semantics for Var. Vars are computed lazily, and the updating thread will receive any exceptions thrown while computing derived Vars.
,Vars do not always perform the minimum amount of re-computation.