yew/examples/async_clock
Marcel ee92b6d305
Async example (#2892)
* Async example

* Formatted

* Demo send_future and send_stream

* Better comment

* Reduce dependencies

* Typo

* Remove tokio_stream dependency

* Remove tokio dependency

* Formatting

* Variety of async methods

* Updated README

* Remove wasm-bindgen-futures dependency
2022-10-03 16:33:16 +05:00
..
2022-10-03 16:33:16 +05:00
2022-10-03 16:33:16 +05:00
2022-10-03 16:33:16 +05:00
2022-10-03 16:33:16 +05:00
2022-10-03 16:33:16 +05:00

Asynchronous coding in Yew

An example of using asynchronous tasks in a component. This example creates a clock in the background and continuously awaits clock-ticks. When the clock updates the new time is sent to the UI component to display. In parallel it fetches online jokes to make the clock more entertaining to watch.

Its main purpose is to demonstrate various ways of using async code in a yew component. It uses the following async features:

  • send_future
  • send_stream
  • spawn_local
  • mpsc::unbounded channels

Running

Run this application:

trunk serve --open