You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#[atom]fna() -> Atom<i32>{0}#[atom]fnb() -> Atom<i32>{0}#[reaction]fna_b_subtraction() -> Reaction<i32>{let a = a().observe();let b = b().observe();
a - b
}#[reaction]fncount_subtraction_when_update() -> Reaction<i32>{let c = c();let _update = a_b_subtraction().on_update(|| {println!("UPDATE !!!");
c.update(|v| *v += 1)});
c.get()}#[test]fntest_on_update_reaction(){let count = count_subtraction_when_update();println!("subtraction value -> {:?}", a_b_subtraction().get());a().update(|v| *v = 32);println!("subtraction value -> {:?}", a_b_subtraction().get());a().set(2);println!("subtraction value -> {:?}", a_b_subtraction().get());a().set(25);println!("subtraction value -> {:?}", a_b_subtraction().get());a().set(1);println!("subtraction value -> {:?}", a_b_subtraction().get());assert_eq!(count.get(),5,"We should get 5 update counted");assert_eq!(count.get(),5);}
Here is the output
Finished test [unoptimized + debuginfo] target(s) in 0.02s
Running target/debug/deps/atomic_hooks-565eb592155b6fce
subtraction value -> 0
subtraction value -> 32
UPDATE !!!
subtraction value -> 2
UPDATE !!!
subtraction value -> 25
UPDATE !!!
subtraction value -> 1
number of updates-> 3
We should get 5 update counted
Left: 3
Right: 5
<Click to see difference>
thread 'reactive_state_access::reaction::test::test_on_update_reaction' panicked at 'assertion failed: `(left == right)`
left: `3`,
right: `5`: We should get 5 update counted', src/reactive_state_access/reaction.rs:705:9
While .get() is working as expected, we have unexpected behavior from .on_update.
How do you think we can fix it ?
The text was updated successfully, but these errors were encountered:
Hello,
So we have this unit test
Here is the output
While
.get()
is working as expected, we have unexpected behavior from.on_update
.How do you think we can fix it ?
The text was updated successfully, but these errors were encountered: