09:48
<Iliasbhal>
Andreu Botella: I just published a new version that polyfills EventTargets 👍️ Feel free to create issues on the repo if you need more API polyfilled.
10:08
<Iliasbhal>
Sidenote: Would you guys accept a PR for the polyfill?
10:09
<Andreu Botella>
Justin Ridgewell:
10:12
<nicolo-ribaudo>
Probably not, as most proposals don't have polyfills and the few that do have a disclaimer "do not actually use this polyfill, it's just meant to be an example". However, you can open an issue linking to it so that other people can find it
10:13
<Andreu Botella>
our repo has an existing polyfill, made by Justin, only for the TC39/JS part of it
10:15
<nicolo-ribaudo>
Oh I didn't notice 😅
10:16
<nicolo-ribaudo>
Btw @iliasbhal:matrix.org the events handling seems to be wrong, as (if I'm reading the code correctly) you are capturing the context when the .addEventListener call happens rather than when the event is dispatched
10:16
<nicolo-ribaudo>
Doing it correctly is much more difficult, but it'd would be very great if a polyfill manages to do it!
10:17
<Andreu Botella>
the semantics of the web integration are explained in https://github.com/tc39/proposal-async-context/blob/master/WEB-INTEGRATION.md
10:17
<nicolo-ribaudo>
"event is dispatched" means, for example, that if you have a XMLHttpRequest object and you listen to it's "load" event, it gets the context from when you call .send() rather than when you call .addEventListener, since .send() is what eventually causes the event to happen
10:17
<Chengzhong Wu>
That was for demonstrating the idea and comparison between SyncContext and AsyncContext. I don't think it is intended for real world use
10:21
<Iliasbhal>
haha! You are reading correctly. But I swear I read the opposite somewhere, or maybe I needed more coffee 🤣 🤦‍♂️ I'll fix that soon 👍️
10:22
<Andreu Botella>
haha! You are reading correctly. But I swear I read the opposite somewhere, or maybe I needed more coffee 🤣 🤦‍♂️ I'll fix that soon 👍️
we actually went back and forth on this, and an earlier version of the proposed web integration did that, so you might not need more coffee 😅
11:03
<Iliasbhal>
nicolo-ribaudo: package updated! The event listener now executes within the same context that when the event was trigered. The event listener can be triggered synchronously or asynchronoulsy it doesn't matter. 👍️
18:39
<Iliasbhal>
Update: I pushed a new version, the way snapshots were collected created memory leak since I was holding strong references to every Async Variables globaly. This prevented them from beeing garbage collected. Even if we never create snapshots. In this new version, I used WeakMaps and WeakSets to hold weak references that won't block anything from beeing garbage collected 👍️