Where this differs from DisposableStack is that disposing it only
resets it after disposing of its dependents, and you can reuse it as many
times as you like. This is very handy for managing lifecycle resources, eg. a
web component can allocate resources in its connectedCallback method and
during its connected lifecycle phase which can all be disposed in
disconnectedCallback with a single call to
DisposableContext.dispose, and it's instantly ready to go again on
reconnect.
A reentrant version of DisposableStack.
This maintains a list of Disposables, added with the DisposableContext.use method, which will all be disposed when you dispose of the DisposableContext itself.
Where this differs from DisposableStack is that disposing it only resets it after disposing of its dependents, and you can reuse it as many times as you like. This is very handy for managing lifecycle resources, eg. a web component can allocate resources in its
connectedCallbackmethod and during its connected lifecycle phase which can all be disposed indisconnectedCallbackwith a single call to DisposableContext.dispose, and it's instantly ready to go again on reconnect.