Skip to content

remove unnecessary gate#439

Merged
leastbad merged 2 commits intostimulusreflex:masterfrom
leastbad:crazy_hunch
Feb 4, 2021
Merged

remove unnecessary gate#439
leastbad merged 2 commits intostimulusreflex:masterfrom
leastbad:crazy_hunch

Conversation

@leastbad
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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