4 releases (2 breaking)
0.3.1 | Jul 31, 2021 |
---|---|
0.3.0 | Jul 26, 2021 |
0.2.0 | Jun 27, 2021 |
0.1.0 | Jun 26, 2021 |
#12 in #reactivity
19KB
529 lines
Fine-grained Reactivity for Rust
Based on: https://indepth.dev/posts/1269/finding-fine-grained-reactive-programming
Example:
fn main() {
let mut a = Signal::new(1);
let mut b = Signal::new(2);
let c;
{
let a = a.clone();
let b = b.clone();
c = Memo::new(move || *a.read() + *b.read());
}
let _effect = Effect::new(move || println!("{}", *c.read()));
*a.write() = 3;
batch(|| {
*a.write() = 10;
*b.write() = 12;
});
}
Will Output:
3
5
22