Stencil needs to be consistent in invoking lifecycle callbacks #4872
TheCelavi
started this conversation in
Stencil Testing
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This discussion is started under premise that strength of library is directly related to the number and popularity of other libraries in user-land domain, which improves developer experience and solves common issues for which core library does not want to or can not provide solution.
In order to provide a good quality libraries and great DX, Stencil must provide consistent API/behaviour, which currently does not when it comes to lifecycle methods. Namely, critical methods of the component class
connectedCallback()
anddisconnectedCallback()
will not be invoked if there is no single component within library which defines those two methods. Reason for that is micro optimisation which provides library benchmark result to compete with others.I am emphasising these two callbacks (
connectedCallback()
anddisconnectedCallback()
) for two reasons:Of course, Stencil SHOULD be consistent - if lifecycle methods are defined via API, they should be either always invoked, or never.
Reason why we are proposing changes in this behaviour is because we just released two experimental libraries for which DX depends on consistency in invocation of lifecycle callbacks, especially
connectedCallback()
anddisconnectedCallback()
:disconnectedCallback()
invocation for each component using it.disconnectedCallback()
.What Stencil also missing is implementation of context protocol (Lit has it) and it is described in fully here: #4431
There is a risk of Stencil team to decline proposal. And certainly, we do not intend to wait for Stencil team to implement it. This can be easily provided in user-land, why not? However, it is clear that consistency in invoking
connectedCallback()
anddisconnectedCallback()
are crucial to provide library of good quality and great DX.We propose for Stencil Team to change compiler behaviour and always invoke lifecycle methods (at least
connectedCallback()
anddisconnectedCallback()
), of course, based on check if component instance has it (this will allow us to add/modify these methods with decorators).If accepted, this would be beneficial for both Stencil and users, we would have reliable and consistent API/behaviour and therefore, we will be able to provide libraries in user-land of good quality and great DX.
Thank you for your time and consideration.
Beta Was this translation helpful? Give feedback.
All reactions