Function ambient_api_core::global::run_async
source · pub fn run_async<R: CallbackReturn>(future: impl Future<Output = R> + 'static)
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!");
});