Skip to content

Commit

Permalink
Export StimulusReflexController constant (#672)
Browse files Browse the repository at this point in the history
## Description

This pull request exports the `StimulusReflexController` constant so it
can be imported from the `stimulus_reflex` package.

## Why should this be added

We already allow developers to customize the default controller used for
the `stimulus-reflex` identifier by passing in the `controller` option
in the `StimulusReflex.initialize(application, options)` call.

This pull requests now allows developers to base their default
controller off the StimulusReflex controller by inheriting from the
`StimulusReflexController` constant, like:

```js
// controllers/default_controller.js
import { StimulusReflexController } from "stimulus_reflex"

export default class extends StimulusReflexController {
  // extend the `stimulus-reflex` controller
}
```

and:
```js
import DefaultController from "../controllers/default_controller"

StimulusReflex.initialize(application, { controller: DefaultController })
```
  • Loading branch information
marcoroth authored Aug 24, 2023
1 parent 8a43fc1 commit 0211cad
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion javascript/stimulus_reflex.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
// that have configured data-reflex. Note that this default can be overridden when initializing the application.
// i.e. StimulusReflex.initialize(myStimulusApplication, MyCustomDefaultController)
//
class StimulusReflexController extends Controller {
export class StimulusReflexController extends Controller {
constructor (...args) {
super(...args)
register(this)
Expand Down

0 comments on commit 0211cad

Please # to comment.