reactive
module · ferroui-view · v0.5.0
module reactive
Fine-grained reactivity: signals, memos, effects and the owners that dispose them.
A Signal holds a value. An effect runs a closure, records the
signals and memos it reads, and runs it again when one of them changes; a
Memo is a value computed the same way and read like a signal. This is
how a property of a control follows state: the element sets the property
from an effect (text: move || format!(..)), so a change updates exactly
that property, with no tree to compare.
Handles are Copy: they are indices into a runtime of the thread, so a
move closure takes a signal without a clone. Every signal, memo and
effect belongs to the Owner that was current when it was made (an
effect is the owner of what is made while it runs), and is disposed with
it: a mounted element tree has an owner that ends with it, and the owner
of an effect disposes what the effect made before it runs again. Using a
handle after its owner was disposed panics.
Changes propagate when the outermost write ends: a write marks the
effects and memos that read the value as dirty, and the dirty effects run
(reading a dirty memo computes it again first). batch defers the runs
until the end of a group of writes.
Contents
Signal— structsignal— functionTwoWay— structMemo— structmemo— functioneffect— functionon_cleanup— functionuntrack— functionbatch— functionOwner— structprovide_context— functionuse_context— function
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.