Function ambient_api::prelude::run_async
source · pub fn run_async<R>(future: impl Future<Output = R> + 'static)where
R: CallbackReturn,
Expand description
Runs the given async block (future
). This lets your module set up behaviour
to run concurrently, like a long-running task. It can return either a ResultEmpty or
nothing.
This is similar to tokio::spawn, as well as similar functions from other async runtimes.
Examples
run_async(async {
notification::broadcast("a title", "hello!");
sleep(2.0).await;
notification::broadcast("a title", "hello to you too!");
});