Skip to main content

Module task

Module task 

Source
Expand description

Async on the UI thread: a small executor driven by Ui::tick, timers on a swappable clock, and a bridge for work done on other threads.

  • spawn_local runs a future on the UI thread. It is owned by the current reactive scope and cancelled when that scope is disposed. Stores’ actions use Store::spawn, which runs it in the store’s scope.
  • spawn_blocking runs a closure on a background thread and resolves (on the UI thread) with its result.
  • sleep waits on the Ui’s clock: real time in apps, a manual clock in tests.

Structs§

ManualClock
A clock that only moves when told to. Share it with Rc to advance it.
Sleep
Future returned by sleep.
SystemClock
Real, monotonic time.
TaskHandle
Handle to a task started with spawn_local.

Traits§

Clock
Time as the UI sees it. Apps use real time; tests use a manual clock.

Functions§

sleep
Waits duration on the current Ui’s clock.
spawn_blocking
Runs work on a background thread; the returned future resolves on the UI thread with its result.
spawn_local
Runs future on the UI thread. It is cancelled when the current reactive scope (e.g. the component that started it) is disposed. A store’s action is called in its caller’s scope: it spawns with Store::spawn instead.