pub fn use_future_with<'hook, F, D, T, O>(
deps: D,
f: F,
) -> impl 'hook + Hook<Output = SuspensionResult<UseFutureHandle<O>>>
Expand description
Use the result of an async computation with dependencies, suspending while waiting.
Awaits the future returned from f
for the latest deps
. Even if the future is immediately
ready, the hook suspends at least once. If the dependencies
change while a future is still pending, the result is never used. This guarantees that your
component always sees up-to-date values while it is not suspended.
ยงNote
When used in function components and hooks, this hook is equivalent to:
pub fn use_future_with<F, D, T, O>(deps: D, f: F) -> SuspensionResult<UseFutureHandle<O>>
where
F: FnOnce(Rc<D>) -> T,
T: Future<Output = O> + 'static,
O: 'static,
D: PartialEq + 'static,
{
/* implementation omitted */
}