Identified cause of radio button bug.

This commit is contained in:
Samuel Guerra 2023-06-18 01:00:35 -03:00
parent 012f54e470
commit baddf97d41
2 changed files with 29 additions and 0 deletions

View File

@ -67,6 +67,19 @@
* Button example, radio button starts without all unchecked.
- Localize example also did not show any selected.
- Window example, background.
- If `let _ = state.set_ne(source.get());` is not called before binding in `bind_is_state` in `is_checked` it works.
- `set_ne` schedules a sets to `false`.
- `source` has already schedules a set to `true`.
- Now that binding updates all happen first, the var set to `true` than `false`.
- How to solve:
- Schedule the first assign, instead of `set_ne`, `modify(|v| *v.set(source.get()))`.
- This is very easy for the users to get wrong.
- Implement `set_bind` methods that use this trick.
- Just change `bind` to set on init.
- Is there a single binding that does not set before binding.
- And while we are at it, is there any `VarValue` that cannot also be `PartialEq`?
- We could make all vars updates be `*_ne`, two less things for the users to think about.
* Config example and tests with errors.
* Layer example, anchored does not update while visible.

View File

@ -447,6 +447,22 @@ mod bindings {
assert_eq!(10, b.get());
}
#[test]
fn binding_update_order2() {
let mut app = App::minimal().run_headless(false);
let a = var(0);
let b = var(0);
a.set(1);
b.set(a.get());
a.bind(&b).perm();
app.update(false).assert_wait();
assert_eq!(1, b.get());
}
}
mod context {