What is the problem this feature will solve?
Does it make sense to add a method to AsyncLocalStorage that returns Disposable?
What is the feature you are proposing to solve the problem?
This is the example from AsyncLocalStorage using .run, which introduces a callback and a level of nesting that comes with that.
http.createServer((req,res)=>{asyncLocalStorage.run(idSeq++,()=>{logWithId('start');// Imagine any chain of async operations heresetImmediate(()=>{logWithId('finish');res.end();});});})With with explicit resource management this could be:
http.createServer((req,res)=>{
using _id=asyncLocalStorage._PROPOSED(idSeq++)logWithId('start');// Imagine any chain of async operations heresetImmediate(()=>{logWithId('finish');res.end();});})enterWith currently returns undefined, could that be updated to return a Disposable?
What alternatives have you considered?
This could be built in user-land, I think
function enterWith<T>(als: AsyncLocalStorage<T>, store: T) {
const oldStore = als.getStore()
console.debug(als.enterWith(store))
const dispose = new DisposableStack()
dispose.defer(() => als.enterWith(oldStore))
return dispose
}
What is the problem this feature will solve?
Does it make sense to add a method to AsyncLocalStorage that returns Disposable?
What is the feature you are proposing to solve the problem?
This is the example from AsyncLocalStorage using
.run, which introduces a callback and a level of nesting that comes with that.With with explicit resource management this could be:
enterWithcurrently returnsundefined, could that be updated to return a Disposable?What alternatives have you considered?
This could be built in user-land, I think