Function dioxus_hooks::use_future

source ·
pub fn use_future<T, F, D>(
    cx: &ScopeState,
    dependencies: D,
    future: impl FnOnce(D::Out) -> F
) -> &UseFuture<T>where
    T: 'static,
    F: Future<Output = T> + 'static,
    D: UseFutureDep,
Expand description

A future that resolves to a value.

This runs the future only once - though the future may be regenerated through the UseFuture::restart method.

This is commonly used for components that cannot be rendered until some asynchronous operation has completed.

Whenever the hooks dependencies change, the future will be re-evaluated. If a future is pending when the dependencies change, the previous future will be allowed to continue

  • dependencies: a tuple of references to values that are PartialEq + Clone