xilem icon indicating copy to clipboard operation
xilem copied to clipboard

xilem_web: Add async_repeat

Open flosse opened this issue 1 year ago • 5 comments

flosse avatar Aug 05 '24 11:08 flosse

This is a first attempt to port xilem::async_repeat to xilem_web. But for some reason the example does not compile:

error[E0277]: the trait bound `AsyncRepeat<{closure@xilem_web/web_examples/async_repeat/src/main.rs:21:9: 21:16}, {closure@xilem_web/web_examples/async_repeat/src/main.rs:27:9: 27:49}, Message>: View<AppState, (), ViewCtx, Box<(dyn xilem_web::Message + 'static)>>` is not satisfied
  --> xilem_web/web_examples/async_repeat/src/main.rs:19:39
   |
19 | fn app_logic(state: &mut AppState) -> impl Element<AppState> {
   |                                       ^^^^^^^^^^^^^^^^^^^^^^ the trait `View<AppState, (), ViewCtx, Box<(dyn xilem_web::Message + 'static)>>` is not implemented for `AsyncRepeat<{[email protected]:21:9}, {[email protected]:27:9}, Message>`, which is required by `Fork<xilem_web::elements::html::Div<_, _>, AsyncRepeat<{closure@xilem_web/web_examples/async_repeat/src/main.rs:21:9: 21:16}, {closure@xilem_web/web_examples/async_repeat/src/main.rs:27:9: 27:49}, Message>>: Element<AppState>`

flosse avatar Aug 05 '24 12:08 flosse

So the reason why this doesn't compile has to do with the two different Message types (as well as DynMessage).

Thank you! Now it works :smile:

flosse avatar Aug 05 '24 15:08 flosse

Thank you! Now it works 😄

Good to know, I hope it's the same issue with AfterBuild etc.

The clippy suggestion is pretty dumb why CI fails... As if an endless loop doesn't have any side-effects...

Anyway, that example is somewhat redundant, as that should be a use-case for the new interval view now. (Also I don't think we should use async_repeat_raw in an example, it's IMO mostly a hack to be able to capture stuff.)

Philipp-M avatar Aug 05 '24 15:08 Philipp-M

Anyway, that example is somewhat redundant, as that should be a use-case for the new interval view now.

But now I added the "abort handle", that might be specific to async tasks.

flosse avatar Aug 05 '24 16:08 flosse

Apart of nits, looks good, nice job with the ShutdownSignal.

thank you 😊

flosse avatar Aug 07 '24 22:08 flosse