AsyncSnapshotResultExtension<T> extension
Extension methods on AsyncSnapshot that provide a Result-like API similar to Kotlin and Rust's Result class, but with an additional "pending" state.
- on
Methods
-
expect(
) → T -
Available on AsyncSnapshot<
Expects the snapshot to be Ok and returns the value. Throws a StateError if the snapshot is not Ok.T> , provided by the AsyncSnapshotResultExtension extension -
expectErr(
) → Object -
Available on AsyncSnapshot<
Expects the snapshot to be an Error and returns the error. Throws a StateError if the snapshot is not an Error.T> , provided by the AsyncSnapshotResultExtension extension -
isErr(
) → bool -
Available on AsyncSnapshot<
Checks if the snapshot has an error. ReturnsT> , provided by the AsyncSnapshotResultExtension extensiontrueif the snapshot has an error. -
isOk(
) → bool -
Available on AsyncSnapshot<
Checks if the snapshot has completed successfully (with or without a value). ReturnsT> , provided by the AsyncSnapshotResultExtension extensiontrueif the snapshot is done and has no error. -
isPending(
) → bool -
Available on AsyncSnapshot<
Checks if the snapshot is pending (waiting or none state). ReturnsT> , provided by the AsyncSnapshotResultExtension extensiontrueif the snapshot is in waiting or none state. -
isUndefined(
) → bool -
Available on AsyncSnapshot<
Checks if the snapshot has a null value. ReturnsT> , provided by the AsyncSnapshotResultExtension extensiontrueif the snapshot is ok but the data is null. -
map<
N> (N fn(T)) → AsyncSnapshot< N> -
Available on AsyncSnapshot<
Transforms the snapshot by applying a function to the Ok value, similar to Iterable.map.T> , provided by the AsyncSnapshotResultExtension extension -
mapErr(
Object fn(Object)) → AsyncSnapshot< T> -
Available on AsyncSnapshot<
Transforms the snapshot by applying a function to the Error value.T> , provided by the AsyncSnapshotResultExtension extension -
mapOrElse<
N> ({N ok(T)?, N nullValue(T)?, N err(Object)?, N pending()?}) → N? -
Available on AsyncSnapshot<
Unboxes the snapshot by applying different functions based on the state. This is extremely useful for building UIs!T> , provided by the AsyncSnapshotResultExtension extension -
okOr(
T defaultValue, {bool filterNullish = false}) → T -
Available on AsyncSnapshot<
Gets the Ok value or a default value if the result is not Ok.T> , provided by the AsyncSnapshotResultExtension extension