3 ms·
I think with native Promises (and async/await?) there is currently no way to implement something like Zone.js properly. I've tried to instrument my code manuall
by renke1 3y ago
I think with native Promises (and async/await?) there is currently no way to implement something like Zone.js properly. I've tried to instrument my code manually, but it's really error-prone and verbose. We really need something like https://nodejs.org/api/async_context.html#class-asynclocalstorage https://nodejs.org/api/async_context.html#class-asynclocalst... to be implemented in the browser.
- vmarchaud 3y agoYou can follow [0] which is currently stage 2 to fix this [0]: https://github.com/tc39/proposal-async-context https://github.com/tc39/proposal-async-context
- renke1 3y agoThanks! I was only aware of a Zones proposal which was withdrawn I think.
- no_wizard 3y agoIn addition to this, is the new (stage 3 even!)explicit resource management proposal[0], supported by TypeScript version >= 5.2[1] Though I agree that async context is better fit for this generally, the ERM should be good for telemetry around objects that have defined lifetime semantics, which is a step in the right direction you can use today [0]: https://github.com/tc39/proposal-explicit-resource-management https://github.com/tc39/proposal-explicit-resource-managemen... [1]: https://www.totaltypescript.com/typescript-5-2-new-keyword-using https://www.totaltypescript.com/typescript-5-2-new-keyword-u...