Closed codewithkyle closed 4 years ago
We should also consider moving the web component console log into a custom event. Instead of firing a component-mounted
event we could fire component:mounted
when the component is mounted and component:loaded
when the components script is loaded into the DOM. We could also potentially fire a component:unmounted
event when the components disconnectedCallback()
method is called.
What
We should consider firing off custom events on the
document
when libraries and components have finished loading.Why
There could be a use case where someone is using a state manager that needs to communicate with a component as soon as the component is mounted, however, since web modules always load first they have know idea when the web component has been mounted onto the custom element. With a custom event we could notify the modules that the components have finished loading and they can start calling web component methods without worrying about trying to manage the race conditions.