import { Observable } from "rxjs";
interface Task<T> {
    cancel(withError?: Error): void;
    execute(): Observable<T>;
    toObservable(): Observable<T>;
}
export declare class TaskQueue {
    tasks: Task<any>[];
    private _subscription?;
    private workingState;
    currentTask?: Task<any>;
    constructor();
    addExecutor(executor: () => Observable<any>): Observable<any>;
    addTask(task: Task<any>): Observable<any>;
    cancelAll(withError?: Error): void;
    private processNext;
}
export declare class TaskOperationCanceled extends Error {
    task: Task<any>;
    code: string;
    constructor(task: Task<any>);
}
export declare class CancelableTask<T> implements Task<T> {
    private operation;
    private _canceled;
    private _executed;
    private _subject;
    readonly isCanceled: boolean;
    constructor(operation: () => Observable<T>);
    /**
     * If canceled is called before the execute => do nothing
     * otherwise reject pending request
     * If canceled is called more than once, do nothing
     */
    cancel(withError?: Error): void;
    /**
     * If execute is called after cancel => return operation canceled exception
     * If already executing, return the current execution promise
     */
    execute(): Observable<T>;
    toObservable(): Observable<T>;
}
export {};
