Webcomponents undefining workaround?

I’ve recently talked to @tomlarkworthy about reusable components inside Observablehq. We’ve thought webcomponents as a great way to abstract and encapsulate logic and styles while taking advantage of Observable dataflow. Then I came across this issue, @mbostock noticed back in 2019 :slightly_frowning_face:

I wonder if there is any workaround to invalidate/redefine or any hacks to improve the developer experience better than refreshing the page or recreating multiple distinct elements.

Here’s a possible solution, setting a flag that randomly modifies the custom element name on edits so you can see the updates as you work: Web Components / Observable / Observable


thank you @shancarter that’s a very useful solution!

1 Like

This comment suggests to use the component constructor as a proxy to the actual implementation: