From c73d4df2f266113ab8adc5b3140a1a7c8cfbe714 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Fri, 8 Mar 2024 12:05:17 +0100 Subject: [PATCH] Alter atExit to yield callback for removing the hook --- packages/core/src/runtime/actor.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/core/src/runtime/actor.ts b/packages/core/src/runtime/actor.ts index 929f7d8..3723668 100644 --- a/packages/core/src/runtime/actor.ts +++ b/packages/core/src/runtime/actor.ts @@ -138,8 +138,12 @@ export class Actor { return this._dataflowGraph; } - atExit(a: LocalAction): void { + atExit(a: LocalAction): () => void { this.exitHooks.push(a); + return () => { + const i = this.exitHooks.indexOf(a); + if (i !== -1) this.exitHooks.splice(i, 1); + }; } _terminateWith(reason: Exclude) {