Expand description
Rx means “reactive value” (or “reactive X”). It is a wrapper for a value which changes,
and these changes trigger dependencies to re-run and change themselves.
Because of Rust’s borrowing rules, you can’t just have Rx values change arbitrarily,
because then references will be invalidated. Instead, when an Rx is updated, this update is delayed until there are no mutable references.
Furthermore, you cannot just get a mutable reference to an Rx value, you must set it to an entirely new value.
The way it works is, there is an RxDAG which stores the entire dependency graph, and you can only get a reference to an Rx value
from a shared reference to the graph. The Rxs update when you call RxDAG::recompute, which requires a mutable reference.
Furthermore, Rx closures must have a specific lifetime, because they may be recomputed.
This lifetime is annotated 'c and the same lifetime is for every closure in an RxDAG.
value directly, instead you use an associated function like run_rx to access it in a closure
which can re-run whenever the dependency changes. You can create new Rxs from old ones.
Structs
Index into the DAG which will give you a computed Rx value.
However, to get the value you need a shared reference to the DAG.
You cannot set the value because it’s computed from other values.
View and mutate part of a Var
The DAG is a list of interspersed nodes and edges. The edges refer to other nodes relative to their own position. Later Rxs must depend on earlier Rxs.
Index into the DAG which will give you an Rx variable.
However, to get or set the value you need a shared reference to the DAG.
This value is not computed from other values, instead you set it directly.
Traits
Returns a graph you can write. Note that RxContext and MutRxContext are neither subset nor superset of each other.
You can’t read snapshots without recomputing, and you can’t write inputs.
Returns a graph you can write. Note that RxContext and MutRxContext are neither subset nor superset of each other.
You can’t read snapshots without recomputing, and you can’t write inputs.