function useOperation<TArgs extends readonly unknown[], TResult, TFailure = never>(start: (...args: TArgs) => BridgeOperation<TResult, TFailure> | undefined | PromiseLike<BridgeOperation<TResult, TFailure> | undefined>, options?: OperationControllerOptions<TResult, TFailure>): OperationHandle<TArgs, TResult, TFailure>; Tracks Start admission, pending work, cancellation and terminal feedback of a generated start<Command>() operation for rendering. run always calls the latest start and options, so they may close over the current client. A run that ends cancelled sets cancelled, not error. Unmounting disposes the controller: a run still in flight resolves to undefined and waitForCompletion is not called after it, but accepted work is never cancelled.
const push = useOperation((remote: string) => client?.startPush(remote));
<button disabled={!client || push.pending} onClick={() => push.run("origin")}>Push</button>
{push.pending && <button disabled={push.cancellationRequested} onClick={() => push.cancel()}>Cancel</button>}
{push.cancelled && <p role="status">Push cancelled.</p>}