@tempots/std
AsyncResult variable
A set of utility functions for working with AsyncResult
.
Signature:
AsyncResult: {
notAsked: {
type: "NotAsked";
};
loading<V>(previousValue?: Maybe<V>): AsyncResult<V, never>;
success<V>(value: V): AsyncResult<V, never>;
failure<E>(error: E): AsyncResult<never, E>;
isSuccess<V, E>(r: AsyncResult<V, E>): r is AsyncSuccess<V>;
isFailure<V, E>(r: AsyncResult<V, E>): r is AsyncFailure<E>;
isNotAsked<V, E>(r: AsyncResult<V, E>): r is NotAsked;
isLoading<V, E>(r: AsyncResult<V, E>): r is Loading<V>;
getOrElse<V, E>(r: AsyncResult<V, E>, alt: V): V;
getOrElseLazy<V, E>(r: AsyncResult<V, E>, altf: () => V): V;
getOrNull<V, E>(r: AsyncResult<V, E>): V | null;
getOrUndefined<V, E>(r: AsyncResult<V, E>): Maybe<V>;
getUnsafe: <V, E>(r: AsyncResult<V, E>) => V;
match: <V1, V2, E>(r: AsyncResult<V1, E>, { success, failure, loading, notAsked, }: {
success: (value: V1) => V2;
failure: (error: E) => V2;
loading: (previousValue?: V1) => V2;
notAsked: () => V2;
}) => V2;
whenSuccess: <V, E>(r: AsyncResult<V, E>, apply: (v: V) => void) => AsyncResult<V, E>;
whenFailure: <V, E>(r: AsyncResult<V, E>, apply: (e: E) => void) => AsyncResult<V, E>;
equals: <V, E>(r1: AsyncResult<V, E>, r2: AsyncResult<V, E>, options?: {
valueEquals: (v1: V, v2: V) => boolean;
errorEquals: (e1: E, e2: E) => boolean;
}) => boolean;
all: <V, E>(results: AsyncResult<V, E>[]) => AsyncResult<V[], E>;
ofPromise: <V>(p: Promise<V>) => Promise<AsyncResult<V, Error>>;
}