question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to extend the Stimulus Application class

See original GitHub issue

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 its static start method.

Details

In the Application code, the start static method references the Application class directly instead of using this.

https://github.com/hotwired/stimulus/blob/f690a6a2e856a35ebdb78246285b734da541338e/src/core/application.ts#L19-L23

This means that even if you extend the Application with say a custom method override of load, this custom method will never get used.

Proposal

Using this instead of Application should solve the issue.

  static start(element?: Element, schema?: Schema): Application {
    const application = new this(element, schema)
    application.start()
    return application
  }

Use case

A trivial use case to add extra behaviour to the application stop call.

class MyApplication extends Application {
  stop() {
    super();
    console.log('application stopped');
  }
}

const application= MyApplication.start();
application.stop();

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lb-commented, Nov 2, 2022

Thanks. I still have this on my radar and hope to get a PR up when I get the chance.

0reactions
lb-commented, Nov 17, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Impact of Unemployment and Stimulus Payments on SSI/SSDI
During the pandemic, some eligibility requirements are being waived and some benefits are being extended or expanded. Always check with your state's ...
Read more >
American Rescue Plan | The White House
Extend unemployment insurance · The American Rescue Plan extended unemployment benefits until September 6 with a weekly supplemental benefit of $300 on top...
Read more >
Economic impact payments: What you need to know - IRS
Who is eligible for the economic impact payment? Tax filers with adjusted gross income up to $75,000 for individuals and up to $150,000...
Read more >
Generalization ABA in the Classroom - SharpSchool
Generalization is the ability for a student to perform a skill under different conditions (stimulus generalization), the ability to apply a skill in...
Read more >
COVID-19 Frequently Asked Questions
Q: Can WIOA formula and competitive grants continue to pay wages or ... Include details about how and why COVID-19 disruptions impact the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found