Skip to content
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 useReflex js function to "support" the composable pattern #475

Merged
merged 1 commit into from
Apr 28, 2021

Conversation

marcoroth
Copy link
Member

@marcoroth marcoroth commented Mar 20, 2021

Type of PR

"Feature"

Description

This PR adds theuseReflex() js function to "support" the composable pattern.

Why should this be added

This can be useful if you include a handful of mixins in your connect() function (e.g. some mixins from stimulus-use) and want them to all look similar. StimulusReflex.register(this) would stick out in that matter.

Example

import { Controller } from 'stimulus'
import { useReflex } from 'stimulus_reflex'
import { useResize, useIdle } from 'stimulus-use'

export default class extends Controller {
  connect() {
    useReflex(this)
    useResize(this)
    useIdle(this)
    // ...
  }

  // ...
}

Reference:

Checklist

  • My code follows the style guidelines of this project
  • Checks (StandardRB & Prettier-Standard) are passing
  • This is not a documentation update

This can be useful if you include a handful of mixins in your `connect()`
function (e.g. some mixins from `stimulus-use`) and want them to all look
similar. `StimulusReflex.register(this)` would stick out in that matter.

Usage:

  import { Controller } from 'stimulus'
  import { useReflex } from 'stimulus_reflex'
  import { useResize, useIdle } from 'stimulus-use'

  export default class extends Controller {
    connect() {
      useReflex(this)
      useResize(this)
      useIdle(this)
      // ...
    }

    // ...
  }

Reference:
* https://github.com/stimulus-use/stimulus-use
* https://www.betterstimulus.com/architecture/mixins.html
@leastbad
Copy link
Contributor

Noice!

@leastbad leastbad merged commit 00997cd into stimulusreflex:master Apr 28, 2021
@marcoroth marcoroth deleted the use-reflex branch April 28, 2021 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants