Alter atExit to yield callback for removing the hook

This commit is contained in:
Tony Garnock-Jones 2024-03-08 12:05:17 +01:00
parent 0a0e8050cb
commit c73d4df2f2
1 changed files with 5 additions and 1 deletions

View File

@ -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<ExitReason, null>) {