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

emit custom life-cycle events #559

Merged
merged 2 commits into from
Nov 22, 2021
Merged

Conversation

leastbad
Copy link
Contributor

@leastbad leastbad commented Nov 8, 2021

Type of PR (feature, enhancement, bug fix, etc.)

Feature

Description

Adds custom events so that developers can choose to handle specific Reflex actions. Easier to explain with an example:

// today, we don't know which Reflex action this is for
document.addEventListener('stimulus-reflex:after', event => console.log(event))

// this PR makes it possible to know that it was for the `status` action
document.addEventListener('stimulus-reflex:after:status', event => console.log(event))

Why should this be added

Today, we emit events for Reflex actions in a generic way: https://docs.stimulusreflex.com/guide/lifecycle#life-cycle-events

Discussion with Lorenzo made me realize that we could easily have SR emit both generic and custom events: https://discordapp.com/channels/629472241427415060/733725826411135107/907294392946130985

Checklist

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

@leastbad leastbad added enhancement New feature or request proposal javascript Pull requests that update Javascript code labels Nov 8, 2021
@leastbad leastbad added this to the 3.5 milestone Nov 8, 2021
@leastbad leastbad merged commit 47ac6ff into stimulusreflex:master Nov 22, 2021
@leastbad leastbad deleted the custom_events branch November 22, 2021 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request javascript Pull requests that update Javascript code proposal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant