19:04
<Justin Ridgewell>
either way, if we expect react apps to have 100 of these, O(n) might not be great
React Contexts do not need AC, and I don’t think they’re even compatible beacuse of React’s fiber batching mechanism.
19:06
<Justin Ridgewell>
IIUC, it would make function calls slightly more expensive (one more pointer to copy) but async context switches less expensive. But since function calls are likely more common, it seems like the right trade-off to put it on the agent record.
Sorry, what new thing are we putting on the agent record?
19:26
<Steve Hicks>
The proposal as written puts [[AsyncContextMapping]] on the agent record, and #95 also adds [[ThrowAsyncContextMapping]].
19:27
<Steve Hicks>
to what extent that's just an implementation detail is unclear to me - if an engine wanted to hold it on the execution context, that might be just as feasible?
19:46
<Andreu Botella>
I think for [[AsyncContextMapping]], it'd be implementable as a property of the execution context
19:47
<Andreu Botella>
for [[ThrowAsyncContextMapping]] too I think (or I hope)
19:48
<Andreu Botella>
HTML needs abrupt completions to hold information related to when the exception was thrown, that currently isn't passed along in the spec
19:48
<Andreu Botella>
the idea would be that in a future where that is added to the JS spec, the throw context would be part of that data
19:49
<Andreu Botella>
I haven't fully checked whether the behavior with #95 would be equivalent to that, but ideally it would be
19:54
<littledan>
React Contexts do not need AC, and I don’t think they’re even compatible beacuse of React’s fiber batching mechanism.
Can you elaborate on this? I know it doesn’t need it, but I thought it might be a good fit if async await were to ever be enabled on the client side in conjunction with hooks
20:04
<Justin Ridgewell>
Component functiosn aren’t executed recusively, they’re pushed into a stack to be processed later on. When you return the <Ctx.Provider value=…><Foo /></Ctx.Provider> VDOM, that Foo component won’t be executed within the sync execution of Ctx.Provider. If Foo were to useContext(Ctx), that would be tracked as part of the component’s internal state (which itself is stored in a AC), it woulnd’t store the context on its own AC variable.
20:07
<Justin Ridgewell>
Searching React’s codebase leads me to think there’ll be a single AC/ALS for the VDOM (and another specifically for Server request state)
20:07
<Justin Ridgewell>
Which is exactly how I would implement this.
20:35
<snek>
that's good to hear