import { Option, Result } from "./OptionResult"; import { JsonAsyncData, LooseRecord } from "./types"; declare class __AsyncData { static P: { Done: (value: A_1) => { readonly tag: "Done"; readonly value: A_1; }; NotAsked: { readonly tag: "NotAsked"; }; Loading: { readonly tag: "Loading"; }; }; /** * Create an AsyncData.Done value */ static Done: (value: A_1) => AsyncData; /** * Create an AsyncData.Loading value */ static Loading: () => AsyncData; /** * Create an AsyncData.NotAsked value */ static NotAsked: () => AsyncData; /** * Turns an array of asyncData into an asyncData of array */ static all: []>(asyncDatas: AsyncDatas) => AsyncData<{ [K in keyof AsyncDatas]: AsyncDatas[K] extends AsyncData ? T : never; }>; /** * Turns an dict of asyncData into a asyncData of dict */ static allFromDict: >>(dict: Dict) => AsyncData<{ [K in keyof Dict]: Dict[K] extends AsyncData ? T : never; }>; static equals: (a: AsyncData, b: AsyncData, equals: (a: A_1, b: A_1) => boolean) => boolean; static isAsyncData: (value: unknown) => value is AsyncData; static fromJSON: (value: JsonAsyncData) => Done | Loading | NotAsked; map(this: AsyncData, func: (value: A) => B): AsyncData; flatMap(this: AsyncData, func: (value: A) => AsyncData): AsyncData; /** * For AsyncData>: * * Takes a callback taking the Ok value and returning a new result and returns an AsyncData with this new result */ mapOkToResult(this: AsyncData>, func: (value: A) => Result): AsyncData>; /** * For AsyncData>: * * Takes a callback taking the Error value and returning a new result and returns an AsyncData with this new result */ mapErrorToResult(this: AsyncData>, func: (value: E) => Result): AsyncData>; /** * For AsyncData>: * * Takes a callback taking the Ok value and returning a new ok value and returns an AsyncData resolving to this new result */ mapOk(this: AsyncData>, func: (value: A) => B): AsyncData>; /** * For AsyncData>: * * Takes a callback taking the Error value and returning a new error value and returns an AsyncData to this new result * */ mapError(this: AsyncData>, func: (value: E) => B): AsyncData>; /** * For AsyncData>: * * Takes a callback taking the Ok value and returning an AsyncData */ flatMapOk(this: AsyncData>, func: (value: A) => AsyncData>): AsyncData>; /** * For AsyncData>: * * Takes a callback taking the Error value and returning an AsyncData */ flatMapError(this: AsyncData>, func: (value: E) => AsyncData>): AsyncData>; /** * Returns the value. Use within `if (asyncData.isDone()) { ... }` */ get(this: Done): A; /** * @deprecated */ getWithDefault(this: AsyncData, defaultValue: A): A; getOr(this: AsyncData, defaultValue: A): A; /** * Maps the value if present, returns the fallback otherwise * * (AsyncData\, B, A => B) => B */ mapOr(this: AsyncData, defaultValue: B, mapper: (value: A) => B): B; match(this: AsyncData, config: { Done: (value: A) => B1; Loading: () => B2; NotAsked: () => B3; }): B1 | B2 | B3; tap(this: AsyncData, func: (asyncData: AsyncData) => unknown): AsyncData; toOption(this: AsyncData): Option; isDone(this: AsyncData): this is Done; isLoading(this: AsyncData): this is Loading; isNotAsked(this: AsyncData): this is NotAsked; toJSON(this: AsyncData): JsonAsyncData; } interface Done extends Readonly<__AsyncData> { readonly tag: "Done"; readonly value: A; } interface Loading extends Readonly<__AsyncData> { readonly tag: "Loading"; } interface NotAsked extends Readonly<__AsyncData> { readonly tag: "NotAsked"; } export declare const AsyncData: typeof __AsyncData; export type AsyncData = Done | Loading | NotAsked; export {};