vscode-elements / elements

Web component library for developing Visual Studio Code extensions
https://vscode-elements.github.io
MIT License
156 stars 27 forks source link

Question: Listen event or use MutationObserver? #186

Closed neko-para closed 1 month ago

neko-para commented 1 month ago

I'm trying to wrap these components into Vue component, which could provide better typescript hint.

Currently, I'm a little confuse about whether should I listen to events or just create a mutation observer, to watch the state changing?

Components like radio and checkbox provide change event, which generally give the choice to update the self-changing value (I mean, the value that may changed because of user clicking). However, collapsible doesn't provide event when user open or close it, and I have to use mutation observer to track the changing of open attribute.

Then, which one is suggested? Components like checkbox do have other reflected attributes (like focused), and it seems that using mutation observer is more robust.

bendera commented 1 month ago

The component should emit an event. It's not a big deal, I will add it.