Skip to content

Commit a9dcee3

Browse files
committed
Validation callbacks are now cleaned up
Closes #105
1 parent f85b2f9 commit a9dcee3

File tree

3 files changed

+173
-56
lines changed

3 files changed

+173
-56
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4040
- [#113][113]: `Input` now constraints its internal selection to the value's
4141
length automatically. This fixes an issue where the backspace key no longer
4242
would work after clearing the text field by setting the `Dynamic`.
43+
- Validation callbacks are now associated with the `Dynamic<Validation>` being
44+
created rather than being persisted indefinitely on the source dynamic.
4345

4446
### Added
4547

@@ -81,6 +83,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8183
- `DefaultActiveBackgroundColor`
8284
- `DefaultDisabledForegroundColor`
8385
- `DefaultDisabledBackgroundColor`
86+
- `CallbackHandle` can now be added with other `CallbackHandle`s to merge
87+
multiple handles into a single handle.
88+
- `Dynamic::set_source` allows attaching a `CallbackHandle` to a `Dynamic`,
89+
ensuring the callback stays alive as long as the dynamic has an instance
90+
alive.
8491

8592
[91]: https://github.com/khonsulabs/gooey/issues/91
8693
[92]: https://github.com/khonsulabs/gooey/issues/92

examples/slider.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ fn u8_range_slider() -> impl MakeWidget {
4848
let range = Dynamic::new(42..=127);
4949
let start = range.map_each(|range| *range.start());
5050
let end = range.map_each(|range| *range.end());
51-
(&start, &end).for_each({
51+
range.set_source((&start, &end).for_each({
5252
let range = range.clone();
5353
move |(start, end)| {
5454
range.set(*start..=*end);
5555
}
56-
});
56+
}));
5757

5858
let min = Dynamic::new(u8::MIN);
5959
let min_text = min.linked_string();

0 commit comments

Comments
 (0)