/** * Event Engine managed effects terminate signal module. * * @internal */ import { Subject } from './subject'; export class AbortError extends Error { name = 'AbortError'; constructor() { super('The operation was aborted.'); Object.setPrototypeOf(this, new.target.prototype); } } /** * Event Engine stored effect processing cancellation signal. * * @internal */ export class AbortSignal extends Subject { private _aborted = false; get aborted() { return this._aborted; } throwIfAborted() { if (this._aborted) { throw new AbortError(); } } abort() { this._aborted = true; this.notify(new AbortError()); } }