createCommandController function

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

function createCommandController<TArgs extends readonly unknown[], TReturn>(command: (...args: TArgs) => TReturn): CommandController<TArgs, Awaited<TReturn>, BridgeOutcomeFailure<Awaited<TReturn>>> & Disposable;

Creates the framework-neutral command runner behind useCommand and injectCommand. The command may return a plain value or undefined, for example () => client?.increment() while the client is still connecting. It may also return one of several commands' promises, such as name => name === "save" ? client.save() : client.discard(); the result is then their union and failure the union of their declared failures. A using declaration disposes it where the engine has Symbol.dispose.