-
Notifications
You must be signed in to change notification settings - Fork 425
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
Add ability to set afterLoad
static methods on Controllers
#579
Conversation
|
Yeah - see #574 (comment) Basically, the current static method While A good thing to note is that you can also load a suite of controllers via
If we opt for |
What if we call it But yeah, agreed. The naming is not ideal. I wonder if it's worth to go through a deprecation cycle to align it to |
I think afterApplicationLoad could be confusing in a different way. It may be inferred to be after the application has loaded instead of after this controller is loaded by the application. What if I Update to afterRegister or afterRegistered ? Then can explore a rename if shouldLoad to should register as a seperate issue. |
Looking at this function I can totally understand why it's called stimulus/src/core/application.ts Lines 56 to 65 in da425c4
|
The documentation does reference https://stimulus.hotwired.dev/handbook/installing#using-webpack-helpers |
Note to self - rebase on master now that eslint/prettier is adopted. |
- when a controller is registered, the `afterLoad` static method, if present, will be called - it gets passed the application instance and the identifier that was used to register it - resolves hotwired#574
8deda6d
to
d5b3a53
Compare
Went with shouldLoad because it's called as part of load. Even though the user invocation happens through register. I think @lb- is right to keep this consistent. Also don't think there's enough value in a rename to proceed with a depreciation cycle here to be honest. |
Thanks @dhh & @marcoroth |
afterLoad
static method, if present, will be calledNote: Hopefully I have added things correctly, I could not get the examples working so have only added unit tests.