mirror of https://github.com/linebender/xilem
Mason Only Add While Active (#496)
It's jarring for the example to automatically add to the button count, so this makes it so it only increments while active is true. --------- Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
This commit is contained in:
parent
cfb0ef231e
commit
2dc7b80153
|
@ -92,6 +92,9 @@ fn app_logic(data: &mut AppData) -> impl WidgetView<AppData> {
|
|||
button("Reset", |data: &mut AppData| data.count = 0),
|
||||
flex((fizz_buzz_flex_sequence, flex_sequence)).direction(axis),
|
||||
)),
|
||||
// The following `async_repeat` view only exists whilst the example is in the "active" state, so
|
||||
// the updates it performs will only be running whilst we are in that state.
|
||||
data.active.then(|| {
|
||||
async_repeat(
|
||||
|proxy| async move {
|
||||
let mut interval = time::interval(Duration::from_secs(1));
|
||||
|
@ -102,8 +105,11 @@ fn app_logic(data: &mut AppData) -> impl WidgetView<AppData> {
|
|||
};
|
||||
}
|
||||
},
|
||||
|data: &mut AppData, ()| data.count += 1,
|
||||
),
|
||||
|data: &mut AppData, ()| {
|
||||
data.count += 1;
|
||||
},
|
||||
)
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -115,9 +115,7 @@ struct NoElements;
|
|||
impl ElementSplice<NoElement> for NoElements {
|
||||
fn with_scratch<R>(&mut self, f: impl FnOnce(&mut AppendVec<NoElement>) -> R) -> R {
|
||||
let mut append_vec = AppendVec::default();
|
||||
let ret = f(&mut append_vec);
|
||||
debug_assert!(append_vec.into_inner().is_empty());
|
||||
ret
|
||||
f(&mut append_vec)
|
||||
}
|
||||
|
||||
fn insert(&mut self, _: NoElement) {}
|
||||
|
|
Loading…
Reference in New Issue