Function freya::prelude::use_resource

pub fn use_resource<T, F>(future: impl Fn() -> F) -> UseResource<T>where
    T: 'static,
    F: Future<Output = T> + 'static,
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 canceled before the new one is started.

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