pub trait DeferAsync<T> {
// Required method
fn defer_async<R>(
self,
f: impl AsyncDeferCallback<T, R>,
) -> impl Future<Output = Option<R>> + Send
where R: Send + 'static,
Self: Sized;
}Expand description
Async extension to [UiRunner], allowing to await until deferred closures are executed.
Required Methods§
Sourcefn defer_async<R>(
self,
f: impl AsyncDeferCallback<T, R>,
) -> impl Future<Output = Option<R>> + Send
fn defer_async<R>( self, f: impl AsyncDeferCallback<T, R>, ) -> impl Future<Output = Option<R>> + Send
Awaitable variant of [UiRunner::defer].
This is actually similar to [UiRunner::block_on], but can be used inside async contexts where is important to not block.
The syncrhonous return value of the closure will be returned from the Future.
The Future may give None if it couldn’t receive a value back, because the
widget coudln’t execute the closure. This can happen even without errors if
the widget is dropped before executing the pending closure.