Skip to content

Replace repeatOnAjax with explicit onetime#3442

Merged
fregante merged 5 commits intomasterfrom
remove-repeat-on-ajax
Aug 10, 2020
Merged

Replace repeatOnAjax with explicit onetime#3442
fregante merged 5 commits intomasterfrom
remove-repeat-on-ajax

Conversation

@fregante
Copy link
Member

@fregante fregante commented Aug 8, 2020

Waiting for sindresorhus/onetime#12

Can be reviewed. Doesn't need testing but it's worth a look just in case features need that old specific behavior (unlikely)

@fregante fregante added the meta Related to Refined GitHub itself label Aug 8, 2020
waitForDomReady: false,

/** Whether to re-run `init` on pages loaded via AJAX. @default true */
repeatOnAjax: false,
Copy link
Member

Choose a reason for hiding this comment

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

Want to give an example of using oneTime here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thought about it, but it's not necessary

@fregante fregante marked this pull request as ready for review August 9, 2020 20:42
fregante added a commit that referenced this pull request Aug 10, 2020
@fregante fregante merged commit f527259 into master Aug 10, 2020
@fregante fregante deleted the remove-repeat-on-ajax branch August 10, 2020 21:59
@sindresorhus
Copy link
Member

What's the benefit of this change?

@fregante
Copy link
Member Author

Sorry, I didn't add context:
#3314 (comment)
#3412 (review)

In short, pages can change via ajax, but if repeatOnAjax === false RG won't call their init even if now their include conditions would match.

That logic was never correct; our real intent was only to prevent duplicate execution on the same document, hence the onetime

@sindresorhus
Copy link
Member

Makes sense. I would probably have added a initOnce option or something, since it's used so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta Related to Refined GitHub itself

Development

Successfully merging this pull request may close these issues.

3 participants