AsyncValueConvenience<T> extension
Convenience methods for handling AsyncValues.
Help is wanted here! Please open PRs to add any methods you want! When possible, try to follow function names in Rust for Result/Option:
- on
-
- AsyncValue<
T>
- AsyncValue<
Properties
-
data
→ Option<
T> -
Available on AsyncValue<
Returns any data contained within this AsyncValue, includingT> , provided by the AsyncValueConvenience extensionpreviousData
for the AsyncLoading and AsyncError cases.no setter
Methods
-
dataOr(
T defaultValue) → T -
Available on AsyncValue<
Returns any data contained within this AsyncValue, includingT> , provided by the AsyncValueConvenience extensionpreviousData
for the AsyncLoading and AsyncError cases. -
dataOrElse(
T defaultFn()) → T -
Available on AsyncValue<
Returns any data contained within this AsyncValue, includingT> , provided by the AsyncValueConvenience extensionpreviousData
for the AsyncLoading and AsyncError cases. -
fillInPreviousData(
Option< T> newPreviousData) → AsyncValue<T> -
Available on AsyncValue<
Fills in the AsyncLoading.previousData or AsyncError.previousData withT> , provided by the AsyncValueConvenience extensionnewPreviousData
if AsyncLoading.previousData or AsyncError.previousData are None. If AsyncLoading.previousData or AsyncError.previousData are Some, thennewPreviousData
will not be filled in. -
map<
R> (R mapper(T)) → AsyncValue< R> -
Available on AsyncValue<
Maps an AsyncValueT> , provided by the AsyncValueConvenience extension -
unwrapOr(
T defaultValue) → T -
Available on AsyncValue<
Returns AsyncData.data ifT> , provided by the AsyncValueConvenience extensionthis
is an AsyncData. Otherwise, returnsdefaultValue
. -
unwrapOrElse(
T defaultFn()) → T -
Available on AsyncValue<
Returns AsyncData.data ifT> , provided by the AsyncValueConvenience extensionthis
is an AsyncData. Otherwise, calls and returns the result ofdefaultFn
. -
withoutPreviousData(
) → AsyncValue< T> -
Available on AsyncValue<
Fills in the AsyncLoading.previousData or AsyncError.previousData with None so that there is no previous data whatsoever in the AsyncValue. This also means that data will only be Some when this is AsyncData, which can be useful when you want to erase any non-relevant previous data.T> , provided by the AsyncValueConvenience extension