# reactive

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-view/reactive/

**module** · [`ferroui-view`](/docs/0.5.0/api/ferroui-view/) · v0.5.0

```rust
module reactive
```

Fine-grained reactivity: signals, memos, effects and the owners that
dispose them.

A [`Signal`](/docs/0.5.0/api/ferroui-view/reactive/struct-signal/) holds a value. An [`effect`](/docs/0.5.0/api/ferroui-view/reactive/function-effect/) runs a closure, records the
signals and memos it reads, and runs it again when one of them changes; a
[`Memo`](/docs/0.5.0/api/ferroui-view/reactive/struct-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`](/docs/0.5.0/api/ferroui-view/reactive/struct-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`](/docs/0.5.0/api/ferroui-view/reactive/function-batch/) defers the runs
until the end of a group of writes.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.View/reactive.rs#L1)

## Contents

- [`Signal`](/docs/0.5.0/api/ferroui-view/reactive/struct-signal/) — struct
- [`signal`](/docs/0.5.0/api/ferroui-view/reactive/function-signal/) — function
- [`TwoWay`](/docs/0.5.0/api/ferroui-view/reactive/struct-twoway/) — struct
- [`Memo`](/docs/0.5.0/api/ferroui-view/reactive/struct-memo/) — struct
- [`memo`](/docs/0.5.0/api/ferroui-view/reactive/function-memo/) — function
- [`effect`](/docs/0.5.0/api/ferroui-view/reactive/function-effect/) — function
- [`on_cleanup`](/docs/0.5.0/api/ferroui-view/reactive/function-on_cleanup/) — function
- [`untrack`](/docs/0.5.0/api/ferroui-view/reactive/function-untrack/) — function
- [`batch`](/docs/0.5.0/api/ferroui-view/reactive/function-batch/) — function
- [`Owner`](/docs/0.5.0/api/ferroui-view/reactive/struct-owner/) — struct
- [`provide_context`](/docs/0.5.0/api/ferroui-view/reactive/function-provide_context/) — function
- [`use_context`](/docs/0.5.0/api/ferroui-view/reactive/function-use_context/) — function

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
