rfc: introduce "connected" and "disconnected" lifecycle hooks to FASTElement #6760
Labels
area:fast-element
Pertains to fast-element
status:under-consideration
Issue is being reviewed by the team.
馃挰 RFC
A feature I've been considering recently is the addition of a "connected" and "disconnected" lifecycle hook to FASTElement instances. These callbacks would be invoked by the ElementController just prior to exiting the
connect()
anddisconnect()
methods, respectively.馃敠 Context
Why would we want this? The browser already calls
connectedCallback()
anddisconnectedCallback()
, right? It does, but there-in lies the problem. In SSR scenarios, thedefer-hydration
attribute will prevent the ElementController from performing hydration work during theconnectedCallback
, including initializing template bindings, connecting behaviors, and re-binding observable values, only doing so after thedefer-hydration
attribute is removed. This means the element and ElementController's state within theconnectedCallback
could be very different between CSR and SSR+Hydration.By introducing
connected
(anddisconnected
) and invoking the hooks from the ElementController, authors can craft components that operate under more consistent conditions between CSR and SSR + Hydration. Additionally, using these hooks and failing to call the super method would not break the ElementController.馃捇 Examples
The text was updated successfully, but these errors were encountered: