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

Break infinite loop in sticky manager #284

Merged
merged 3 commits into from
Mar 5, 2019

Conversation

andrewpye
Copy link
Member

Noticed today while testing polaris-sticky in one of our apps that the manageStickyItems method in sticky-manager has an infinite loop, figured I should probably fix it 🤦‍♂️

@andrewpye andrewpye self-assigned this Mar 1, 2019
@andrewpye andrewpye requested review from vladucu and tomnez March 1, 2019 16:11
Copy link
Member

@vladucu vladucu left a comment

Choose a reason for hiding this comment

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

It seems by default Polaris's throttle will have the func invoked on the trailing edge of the timeout only if the throttled function is invoked more than once during the wait timeout while Ember's throttle will trigger the function on the leading instead of the trailing edge of the wait interval

Do you think using throttle with immediate false would do the same? if yes maybe we can get rid of the debounceTask call altogether....but maybe I'm missing something

PS: seems Polaris uses 40 as the timeout instead of 50 for the throttles

@andrewpye
Copy link
Member Author

It seems by default Polaris's throttle will have the func invoked on the trailing edge of the timeout only if the throttled function is invoked more than once during the wait timeout

Not quite, from what I can see - this is only if both leading: true and trailing: true are specified. The default behaviour seems to be trailing.

Do you think using throttle with immediate false would do the same?

I'll try this, you might be onto something 👍

PS: seems Polaris uses 40 as the timeout instead of 50 for the throttles

Nowadays yes, but not on v2.11.0 which we currently mimic...

@andrewpye andrewpye requested a review from vladucu March 4, 2019 15:50
@andrewpye
Copy link
Member Author

@vladucu updated (and now the diff's best viewed with whitespace diffing disabled)

@andrewpye andrewpye merged commit 14b25df into master Mar 5, 2019
@delete-merged-branch delete-merged-branch bot deleted the fix/sticky-manager-infinite-loop branch March 5, 2019 10:31
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.

None yet

2 participants