import { Subject } from 'rxjs';
export declare namespace TaskManager {
    type TaskState = 'pending' | 'running' | 'delayed' | 'done';
    type Event<TaskContext, TaskResult = unknown> = BeforeTaskEvent<TaskContext> | AfterTaskEvent<TaskContext, TaskResult> | CancelTaskEvent<TaskContext> | ErrorTaskEvent<TaskContext>;
    interface BeforeTaskEvent<TaskContext> {
        type: 'BEFORE_TASK';
        task: Task<TaskContext>;
    }
    interface AfterTaskEvent<TaskContext, TaskResult> {
        type: 'AFTER_TASK';
        task: Task<TaskContext, TaskResult>;
        result: TaskResult;
    }
    interface CancelTaskEvent<TaskContext> {
        type: 'CANCEL_TASK';
        task: Task<TaskContext>;
    }
    interface ErrorTaskEvent<TaskContext> {
        type: 'ERROR_TASK';
        task: Task<TaskContext>;
        error: Error;
        delayed: boolean;
    }
    interface Task<TaskContext, TaskResult = unknown> {
        id: string;
        info?: {
            title: string;
        };
        exec(context: TaskContext): Promise<TaskResult>;
        cancel?(): any;
    }
    interface TaskContainer<TaskContext, TaskResult = unknown> {
        task: TaskManager.Task<TaskContext, TaskResult>;
        events: Subject<TaskManager.Event<TaskContext, TaskResult>>;
        meta: {
            state: TaskManager.TaskState;
            result?: TaskResult;
            error?: Error;
            context?: any;
        };
    }
}
