Re: [heycam/webidl] Introduce the observable array type (proxy-based) (#840)

> My conclusion in [WICG/construct-stylesheets#118 (comment)](https://github.com/WICG/construct-stylesheets/issues/118#issuecomment-588474978) is that at the spec level we would only need the IDL-maintained mirror list ("backing list") and wouldn't even need the add/remove hooks.

Hmm.  That's assuming that something else effectively polls the list, right?  That is, instead of having an explicit "this list got changed, go flag the rendering as needing updating" in the spec we'd just say in places that update the rendering or compute styles that they need to get the current values in the list.

> I mean, implementations will probably want them, I think?

Right, implementations are going to want to invalidate cached information when the list mutates and whatnot.

And good catch about the "add" hook.

That said, if we maintain the mirror directly in the proxy, as a matter of what the spec looks like we could do the following:

1) Have the target be an array.
2) Have a slot with the "mirror" list (which is actually just The List).
3) Indexed props and "length" just read/modify the mirrored list; don't touch the array at all.
4) Other props, proto gets/modifications, etc go through to the array, for convenience.

This does require implementing a bunch of proxy hooks, unfortunately.  But it makes it very clear what the state of the list is, and implementations can do whatever they want in terms of the list maintenance, including whatever internal callbacks they like when it mutates, and it's very clear that that's identical to the spec behavior.

Note that I have not had a chance to read the most recent updated diff yet, so maybe that's what it's already doing.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/pull/840#issuecomment-589293841

Received on Thursday, 20 February 2020 20:30:35 UTC