useAsyncValue<T> function

AsyncValue<T> useAsyncValue<T>(
  1. Future<T> future(), [
  2. List<Object?> keys = const <Object>[]
])

Turn the Future returned by future into an AsyncValue.

The returned future is memoized and re-evaluated whenever keys change.

Implementation

AsyncValue<T> useAsyncValue<T>(
  Future<T> Function() future, [
  List<Object?> keys = const <Object>[],
]) =>
    useFuture(
      useMemoized(() => AsyncValue.guard(future), keys),
      initialData: AsyncValue<T>.loading(),
    ).data!;