CommandController interface

Namespace @runic-artifex/views · @runic-artifex/views 0.7.0-preview.5

interface CommandController<TArgs extends readonly unknown[], TResult, TFailure = BridgeOutcomeFailure<TResult>>

Runs a command and tracks whether it is pending and why it last failed.

Properties

current

readonly current: CommandState<TFailure>;

No documentation.

Methods

subscribe

subscribe(listener: () => void): () => void;

Calls listener after each change of current, until the returned function is called.

run

run(...args: TArgs): Promise<TResult | undefined>;

Runs the command. Starting a run clears error and failure. Resolves to the command's result, including a BridgeOutcome with a declared failure, or to undefined after an unexpected failure. error and failure are set only if no later run started meanwhile. It never rejects, so callers need no try/catch.

reset

reset(): void;

Clears error and failure. Runs still in flight count as superseded: they settle without setting either, as when a later run starts.

dispose

dispose(): void;

Stops publishing; runs still in flight settle without updating state.