pub struct RxDAG<'c>(_, _);
Expand description

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.

When the DAG recomputes, it simply iterates through each node and edge in order and calls RxDAGElem::recompute. If the nodes were changed (directly or as edge output), they set their new value, and mark that they got recomputed. The edges will recompute and change their output nodes if any of their inputs got recomputed.

The DAG has interior mutability, in that it can add nodes without a mutable borrow. See elsa crate for why this is sound (though actually the soundness argument is contested). Internally we use a modified version because of elsa and stable-deref-trait

Setting Rx values is also interior mutability, and OK because we don’t use those values until RxDAGElem::recompute.

The DAG and refs have an ID so that you can’t use one ref on another DAG, however this is checked at runtime. The lifetimes are checked at compile-time though.

Currently no Rxs are deallocated until the entire DAG is deallocated, so if you keep creating and discarding Rxs you will leak memory (TODO fix this?)

Implementations

Create an empty DAG

Create a variable Rx in this DAG.

Run a closure when inputs change, without creating any outputs (for side-effects).

Create a computed Rx in this DAG.

Create 2 computed Rx in this DAG which are created from the same function.

Create 3 computed Rx in this DAG which are created from the same function.

Update all Vars with their new values and recompute Rxs.

Recomputes if necessary and then returns a RxContext you can use to get the current value.

Returns a RxContext you can use to get the current value. However any newly-set values or computations will not be returned until recompute is called.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.