webcomponents-cg / community-protocols

Cross-component coordination protocols
179 stars 12 forks source link

[context] Declarative alternative #44

Closed rektide closed 1 year ago

rektide commented 1 year ago

I'm pretty surprised to see such an event-based implementation for context.

I'd love to see an alternative proposal offered for context that is declarative in nature. Existing APIs like onchange seem to offer pretty good hooks we could use to do a lot of the change detection. But meanwhile, we could be embedding more of the context on the page itself.

Different topic but for example https://github.com/WICG/webcomponents/issues/1013 is talking about instantiating DOM Templates with microdata: that microdata or something sort of like it feels like what context could or should be.

There's no concrete proposals here. But I see the current shape & see issues like #39 which push to make context ever more ephemeral, with an event-based request-response protocol, and I just wish so much the declarative DOM could be leveraged to let us not need to add a bunch of new custom protocols. The challenge of context, to me, is embedding data in the dom & using it: that let's us do most of the work with what we already have, rather than invent so much new stuff.

Westbrook commented 1 year ago

Would you happen to have any broad strokes of an alternative approach here?

State inherently means that this will be happening in a JS context which means something will always be imperative about this code unless we magically get a full scripting extension to the language of HTML, so I'm not sure something like this could ever be fully declarative.

Without further insight or suggestion, closing as not actionable.