import { ICommandState } from "./_types/ICommandState"; import { Field, IDataHook } from "model-react"; import { Resource } from "./dependencies/Resource"; import { ICommandMetadata } from "./_types/ICommandMetadata"; import { ICommand } from "./_types/ICommand"; /** * A base class for commands */ export declare abstract class Command implements ICommand { abstract metadata: ICommandMetadata; protected state: Field; protected readonly dependencies: Resource[]; protected queue: { type: "execute" | "revert"; promise: Promise; resolve: () => void; reject: (error: any) => void; dependencies: Promise<() => void>; }[]; /** * Executes the command * @returns A promise that resolves once execution finished */ execute(): Promise; /** * Reverts the command * @returns A promise that resolves once reverting finished */ revert(): Promise; /** * Adds a request to the queue * @param type The type of request to add * @returns The promise that resolves once the request is handled */ protected addQueue(type: "execute" | "revert"): Promise; /** * Dispatches another execute or revert request if any remain */ protected dispatch(): Promise; /** * Acquires the dependencies * @returns A function that can be used to release the dependencies */ protected acquireDependencies(): Promise<() => void>; /** * Retrieves the state of the command * @param hook The hook to subscribe to changes * @returns The state of the command */ getState(hook?: IDataHook): ICommandState; /** The code to call on execute */ protected abstract onExecute(): void | Promise; /** The code to call on revert */ protected abstract onRevert(): void | Promise; } //# sourceMappingURL=Command.d.ts.map