-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The order of the lifecycle callbacks is confusing Stimulus 3 #471
Comments
cc @seanpdoyle |
seanpdoyle
added a commit
to seanpdoyle/stimulus
that referenced
this issue
Oct 11, 2021
Closes hotwired#471 --- This commit re-arranges the documentation for Controller Lifecycle Callbacks to reflect the order of execution and elaborates with more details when possible. The possibilities for the callback execution order was discussed and the [current order was agreed upon][order]. [order]: hotwired#367
I've opened #473 to improve the documentation around the lifecycle execution order. |
dhh
pushed a commit
that referenced
this issue
Oct 11, 2021
Closes #471 --- This commit re-arranges the documentation for Controller Lifecycle Callbacks to reflect the order of execution and elaborates with more details when possible. The possibilities for the callback execution order was discussed and the [current order was agreed upon][order]. [order]: #367
Thank you @dhh and @seanpdoyle! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the documentation the following callbacks are defined:
initialize() | Once, when the controller is first instantiated
connect() | Anytime the controller is connected to the DOM
[name]TargetConnected(target: Element) | Anytime a target is connected to the DOM
disconnect() | Anytime the controller is disconnected from the DOM
[name]TargetDisconnected(target: Element) | Anytime a target is disconnected from the DOM
And in my case I use the connect() and [name]TargetConnected(target: Element) callbacks. I would expect the connect callback to be called first but to my surprise the [name]TargetConnected callbacks are being called before the connect callback. I would expect them to be called in the same order as the order in the documentation.
In my dom I have something like this:
Console output:
The text was updated successfully, but these errors were encountered: