Created
January 2, 2026 15:43
-
-
Save aquapi/9adb19ad84e846c0d1a24865233049ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // DisposableStack fork | |
| using parentStack = new DisposableStack(); | |
| const childStack = parentStack.use(new DisposableStack()); | |
| // DisposableStack register with dispose callback (should be cached) | |
| const stack = new DisposableStack(); | |
| stack.adopt(resource, (resource) => { | |
| // Dispose resource | |
| }); | |
| // DisposableStack register a disposable | |
| stack.use(disposableResource); | |
| // DisposableStack register onDispose callback | |
| stack.defer(() => { | |
| // Run on dispose | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment