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
Ability to extend the Stimulus Application class #586
Comments
Hey @lb-, thanks for opening this issue. I think your proposal makes sense and we could implement this. Feel free to open a pull request for it! Thank you! |
Thanks @marcoroth - should this be documented anywhere? Or is it best left undocumented? I would assume we would add a section around the application debugging or before the application error callback section? |
I would probably have left it undocumented, since it's technically "just" regular class inheritance at work. But I wouldn't be opposed to having a small note/example in the documentation for it. |
Thanks. I still have this on my radar and hope to get a PR up when I get the chance. |
When using const application = MyApplication.start() - it now will use the actual MyApplication class instead of the non-extended Application class Fixes hotwired#586
- When using const application = MyApplication.start() - it now will use the actual MyApplication class instead of the non-extended Application class - Fixes hotwired#586
PR up #603 |
Summary
Class inheritance provides a way to achieve custom behaviour and it would be great to also allow this at the
Application
level.Currently, it is not easy to extend and use the
Application
class without rewriting itsstatic start
method.Details
In the Application code, the
start
static method references theApplication
class directly instead of usingthis
.stimulus/src/core/application.ts
Lines 19 to 23 in f690a6a
This means that even if you extend the
Application
with say a custom method override ofload
, this custom method will never get used.Proposal
Using
this
instead ofApplication
should solve the issue.Use case
A trivial use case to add extra behaviour to the application stop call.
The text was updated successfully, but these errors were encountered: