DEV Community

Discussion on: We Should Stop Hating Web Components

Collapse
 
theharshsingh profile image
Harsh Singh • Edited

Everything you mentioned above is already implemented in Web Components.

  • A Robust Standard has already been laid out. You can readily use web components in any framework just like any other HTML element. Angular already uses Web Components under the hood.
  • You can observe when a property changes and react to those changes by declaring the attributes you want inside the static get observedAttributes method inside the class and a method called attributeChangedCallback will be invoked every time the attribute changes which will provide you with both its previous and current value so you can compare the changes
  • You can use CustomEvents API for creating and dispatching custom events and you can use any framework agnostic state management library for managing the global state. and for local state you can use getters/setters