import { Abortable } from '../abortable/abortable.class'; import { IAsyncTaskAllSettledValuesListReturn } from './async-task-all-settled-values-list-return.type'; import { IAsyncTaskConstraint } from './types/async-task-constraint.type'; import { IAsyncTaskInput } from './types/async-task-input.type'; import { IAsyncTaskFactory } from './types/factory/async-task-factory.type'; import { IGenericAsyncTaskFactoriesList } from './types/factory/generic-async-task-factories-list.type'; import { IAsyncTaskInitFunction } from './types/init/async-task-init-function.type'; import { IAsyncTaskOnAbortedFunction } from './types/methods/aborted/async-task-on-aborted-function.type'; import { IAsyncTaskOnErroredFunction } from './types/methods/errored/async-task-on-errored-function.type'; import { IAsyncTaskOnFinallyFunction } from './types/methods/finally/async-task-on-finally-function.type'; import { IAsyncTaskOnSuccessfulFunction } from './types/methods/successful/async-task-on-successful-function.type'; import { IAsyncTaskAllValuesListReturn } from './types/static-methods/all/async-task-all-values-list-return.type'; import { IAsyncTaskRaceValueReturn } from './types/static-methods/race/async-task-race-value-return.type'; export declare const ASYNC_TASK_SUCCESS: unique symbol; export declare class AsyncTask> { #private; /** * Creates an AsyncTask from an IAsyncTaskFactory. */ static fromFactory>(factory: IAsyncTaskFactory, abortable: Abortable): AsyncTask; /** * Creates a "successful" AsyncTask. * If "value" is an AsyncTask or Promise, then the returned AsyncTask will take the same state when resolved. */ static success>(value: IAsyncTaskInput, abortable: Abortable): AsyncTask; /** * Creates an "errored" AsyncTask. */ static error = any>(_error: any, abortable: Abortable): AsyncTask; /** * Creates an AsyncTask that never complete (never enter in a "success" or "error" state). * However, it can still be aborted. */ static never = any>(abortable: Abortable): AsyncTask; /** * Creates a "successful" AsyncTask, whose value is "undefined". */ static void(abortable: Abortable): AsyncTask; /** * Creates a AsyncTask, whose Abortable is aborted when "success" or "error" is called. * This is sometimes useful to clear some resources. */ static abortOnFinished>(init: IAsyncTaskInitFunction, abortable: Abortable): AsyncTask; /** * Returns an AsyncTask resolved with all the values returned by the factories (as an array). * If any of the AsyncTasks returned by the factories enters in an "error" state, the returned AsyncTask enters in an "error" state too, * add all other factories are aborted. */ static all(factories: GFactories, abortable: Abortable): AsyncTask>; /** * Returns an AsyncTask resolved with the first value or error returned by the factories. * When it appends, all the other factories are aborted. */ static race(factories: GFactories, abortable: Abortable): AsyncTask>; /** * Returns a "successful" AsyncTask when all the factories are resolved. * The result is an array with the state of each of these factories. */ static allSettled(factories: GFactories, abortable: Abortable): AsyncTask>; constructor(init: IAsyncTaskInitFunction, abortable: Abortable); then>(onSuccessful: IAsyncTaskOnSuccessfulFunction, onErrored: IAsyncTaskOnErroredFunction): AsyncTask; successful>(onSuccessful: IAsyncTaskOnSuccessfulFunction): AsyncTask; errored>(onErrored: IAsyncTaskOnErroredFunction): AsyncTask; aborted>(onAborted: IAsyncTaskOnAbortedFunction, abortable?: Abortable): AsyncTask; switchAbortable(abortable: Abortable): AsyncTask; finally(onFinally: IAsyncTaskOnFinallyFunction): AsyncTask; toPromise(): Promise; }