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

remove unnecessary gate #439

Merged
merged 2 commits into from
Feb 4, 2021
Merged

Conversation

leastbad
Copy link
Contributor

@leastbad leastbad commented Feb 3, 2021

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

"Enhancement"

Description

Back in #45 (aka callbacks) we introduced a gate around the bottom-half of the main stimulus_reflex.js to make sure it was only executed once. The thing is, I cannot for the life of me see what purpose this serves. Presumably, with or without Turbolinks, this code is only going to be executed once per page - or else the const initialize immediately above it would already be complaining loudly, right?

This PR just removes the gate. There could be a very good reason to keep it! I just don't know what we were guarding against.

Why should this be added

Code clarity

Checklist

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

@leastbad
Copy link
Contributor Author

leastbad commented Feb 4, 2021

Note that the file view on this PR looks intimidating, but it's literally just removing lines 494-496, 604.

The changeset is the result of the indentation formatting moving everything two spaces to the left.

@leastbad leastbad added javascript Pull requests that update Javascript code proposal labels Feb 4, 2021
@leastbad leastbad added this to the 3.4.2 milestone Feb 4, 2021
Copy link
Contributor

@hopsoft hopsoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be safe considering that SR is typically initialized in app/javascript/controllers/index.js or somewhere similar.

@leastbad leastbad merged commit ba5a9ca into stimulusreflex:master Feb 4, 2021
@leastbad leastbad deleted the crazy_hunch branch February 4, 2021 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
javascript Pull requests that update Javascript code proposal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants