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

use throttle instead of debounce #17

Merged
merged 1 commit into from
Aug 4, 2021
Merged

use throttle instead of debounce #17

merged 1 commit into from
Aug 4, 2021

Conversation

missinglink
Copy link
Contributor

@missinglink missinglink commented Jul 31, 2021

this PR is a replacement for #16 which is preferable since it's using a well tested implementation.

It replaces _.debounce with _.throttle and updates the API. This is a breaking change.

@missinglink
Copy link
Contributor Author

missinglink commented Aug 3, 2021

Actually.. I think we should change the settings to { leading: true, trailing: true }.

The rationale is that connection latency will only ever affect the first 'paint' of the UI.

If the browser is sending requests every delay D and the connection has latency L, then the UI 'paints' will always follow the same pattern regardless of the connection speed:

note: I'm just showing the 'deltas' ie. the difference in time from when the previous response was received

{ leading: false, trailing: true }

D+L, D, D, D, D....
{ leading: true, trailing: true }

L, D, D, D, D....

In both of these scenarios, L only appears once, but with the second config slower connections are receiving their first request as quickly as they possibly can.

mxlje added a commit that referenced this pull request Aug 4, 2021
mxlje added a commit that referenced this pull request Aug 4, 2021
@mxlje mxlje merged commit 507137d into main Aug 4, 2021
@mxlje mxlje deleted the throttle branch August 4, 2021 11:27
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