mini_rx/
lib.rs

1#![feature(decl_macro)]
2
3#![feature(generic_associated_types)]
4
5#![feature(iter_collect_into)]
6#![feature(cell_update)]
7#![feature(unboxed_closures)]
8#![feature(fn_traits)]
9
10//! `Rx` means "reactive value" (or "reactive X"). It is a wrapper for a value which changes,
11//! and these changes trigger dependencies to re-run and change themselves.
12//!
13//! Because of Rust's borrowing rules, you can't just have `Rx` values change arbitrarily,
14//! because then references will be invalidated. Instead, when an `Rx` is updated, this update is delayed until there are no mutable references.
15//! Furthermore, you cannot just get a mutable reference to an `Rx` value, you must set it to an entirely new value.
16//!
17//! 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
18//! from a shared reference to the graph. The `Rx`s update when you call [RxDAG::recompute], which requires a mutable reference.
19//!
20//! Furthermore, `Rx` closures must have a specific lifetime, because they may be recomputed.
21//! This lifetime is annotated `'c` and the same lifetime is for every closure in an [RxDAG].
22//! value directly, instead you use an associated function like [RxDAG::run_rx] to access it in a closure
23//! which can re-run whenever the dependency changes. You can create new `Rx`s from old ones.
24
25pub(crate) mod misc;
26pub(crate) mod dag;
27pub(crate) mod dag_uid;
28pub(crate) mod rx_impl;
29pub(crate) mod rx_ref;
30pub(crate) mod clone_set_fn;
31
32pub use dag::*;
33pub use rx_ref::*;
34pub use clone_set_fn::*;