3 releases

0.1.0-alpha.3 Nov 12, 2024
0.1.0-alpha.1 Nov 11, 2024

#122 in Caching

Download history 308/week @ 2024-11-08 50/week @ 2024-11-15 7/week @ 2024-11-22 17/week @ 2024-12-06

86 downloads per month

MIT license

12KB
275 lines

lazy_catch


lib.rs:


let mut system = System::new();

let arc_x = std::sync::Arc::new(system.var(0));

assert_eq!(*system.get(&*arc_x), 0);

let a = system.val(|mut u: Update<i32>| {
    let v = *u.get(&*arc_x);
    u.update(|| v + 1);
});
assert_eq!(*system.get(&a), 1);

let arc_x_clone = arc_x.clone();
let b = system.sync_val(move |mut u: Update<i32>| {
    let v = *u.get(&*arc_x_clone);
    u.update(|| v + 2);
});
let mut modify = system.modify();
*arc_x.modify(&mut modify) = 10;

std::thread::spawn(move || {
    assert_eq!(*system.get(&b), 12);
}).join().unwrap();

No runtime deps