MockOperation interface

Module @runic-artifex/views/mock in @runic-artifex/views 0.23.0

interface MockOperation<TInput = unknown, TResult = unknown>

An operation a client started with start{Command}().

Properties

member

readonly member: string;

The command's wire name.

requestId

readonly requestId: string;

The operation id.

input

readonly input: TInput;

No documentation.

kind

readonly kind: MockOperationKind;

No documentation.

signal

readonly signal: AbortSignal;

Aborts when the client cancels the operation or the wait times out.

items

readonly items: readonly TResult[];

The stream values emitted so far.

progress

readonly progress: number | undefined;

The latest progress the operation reported, from 0 to 1, or undefined.

Methods

reportProgress

reportProgress(value: number): void;

Reports progress, clamped to 0 to 1; watching clients receive it as running with progress.

succeed

succeed(result?: TResult): void;

No documentation.

fail

fail(message?: string, detail?: BridgeFailureDetail): void;

No documentation.

failWith

failWith(failure: unknown): void;

Ends the operation with its declared failure (domain-failed), as a wire value.

cancel

cancel(): void;

No documentation.

expire

expire(): void;

Drops the finished operation's outcome, as a producer does when its retention runs out: its status, watch, stream and cancel then answer expired, and a start that repeats its id and input answers expired. Throws for a running operation, which a producer does not expire.

forget

forget(): void;

Forgets the operation id, as a restarted window has: its status, watch, stream and cancel then answer unknown, and a start with the id starts a new operation. A running operation's signal aborts, and a later outcome of its handler is ignored.

emit

emit(...items: TResult[]): void;

Appends values to a stream operation.