import { CancelToken } from 'axios'; export declare type Cancel = (reason?: string, info?: any) => void; export declare type PayloadState = 'nothing' | 'value' | 'loading' | 'error'; export declare const PayloadState: { Nothing: "nothing"; Value: "value"; Loading: "loading"; Error: "error"; }; export declare abstract class PayloadBase { abstract match(matcher: PayloadMatcher): R; isReady(matcher?: Partial>): boolean; } export declare class PayloadValue extends PayloadBase implements PayloadApi { state: "value"; value: T; meta: any; constructor(entity: T, meta?: any); isValue(this: Payload): this is PayloadValue; isLoading(this: Payload): this is PayloadLoading; isError(this: Payload): this is PayloadError; isNothing(this: Payload): this is PayloadNothing; match(matcher: PayloadMatcher): R; andThen(op: (a: T) => Payload): Payload; map(op: (a: T) => U): Payload; orElse(_: (a: Error) => Payload): Payload; unwrapOr(_or: R): T | R; unwrapOrElse(_: (e?: Error) => R): T | R; } export declare class PayloadLoading extends PayloadBase implements PayloadApi { __brand: T; state: "loading"; meta: any; cancel: () => void; constructor(cancel?: Cancel, meta?: {}); isValue(this: Payload): this is PayloadValue; isLoading(this: Payload): this is PayloadLoading; isError(this: Payload): this is PayloadError; isNothing(this: Payload): this is PayloadNothing; match(matcher: PayloadMatcher): R; andThen(_op: (a: T) => Payload): Payload; map(_op: (a: T) => U): Payload; unwrapOr(def: R): T | R; unwrapOrElse(def: (e?: Error) => R): T | R; } export declare class PayloadError extends PayloadBase implements PayloadApi { __brand: T; state: "error"; meta: any; error: Error; constructor(error: Error, meta?: {}); isValue(this: Payload): this is PayloadValue; isLoading(this: Payload): this is PayloadLoading; isError(this: Payload): this is PayloadError; isNothing(this: Payload): this is PayloadNothing; unwrapOr(def: R): T | R; unwrapOrElse(def: (error?: Error) => R): T | R; map(_op: (a: T) => U): Payload; andThen(_op: (a: T) => Payload): Payload; match(matcher: PayloadMatcher): R; } export declare class PayloadNothing extends PayloadBase implements PayloadApi { __brand: T; state: "nothing"; meta: any; constructor(meta?: {}); isValue(this: Payload): this is PayloadValue; isLoading(this: Payload): this is PayloadLoading; isError(this: Payload): this is PayloadError; isNothing(this: Payload): this is PayloadNothing; unwrapOr(def: R): T | R; unwrapOrElse(def: (error?: Error) => R): T | R; andThen(_op: (a: T) => Payload): Payload; map(_op: (a: T) => U): Payload; match(matcher: PayloadMatcher): R; } export interface PayloadApi { state: PayloadState; isValue(this: Payload): this is PayloadValue; isLoading(this: Payload): this is PayloadLoading; isError(this: Payload): this is PayloadError; isNothing(this: Payload): this is PayloadNothing; match(matcher: PayloadMatcher): R; isReady(matcher?: Partial>): boolean; andThen(op: (a: T) => Payload): Payload; map(op: (a: T) => U): Payload; unwrapOr(or: R): T | R; unwrapOrElse(or: (e?: Error) => R): T | R; } export declare type Payload = PayloadValue | PayloadError | PayloadLoading | PayloadNothing; export declare function all(payloads: Payload[]): Payload; export declare const Payload: { State: { Nothing: "nothing"; Value: "value"; Loading: "loading"; Error: "error"; }; Value: typeof PayloadValue; Loading: typeof PayloadLoading; Error: typeof PayloadError; Nothing: typeof PayloadNothing; isError: typeof isError; isValue: typeof isValue; isNothing: typeof isNothing; isLoading: typeof isLoading; fromPromise: typeof fromPromise; all: typeof all; }; export default Payload; export declare function isValue(load: Payload): load is PayloadValue; export declare function isLoading(load: Payload): load is PayloadLoading; export declare function isError(load: Payload): load is PayloadError; export declare function isNothing(load: Payload): load is PayloadNothing; export interface PayloadMatcher { Nothing: () => R; Value: (entity: T) => R; Loading: (cancel: Cancel) => R; Error: (error: Error) => R; } export declare function cancellify(promise: Promise, cancelToken: CancelToken): Promise; export declare function fromPromise(opts: { promise: Promise; cancel?: Cancel; cancellable?: boolean; update: (p: Payload) => void; }): Promise; //# sourceMappingURL=payload.d.ts.map