Skip to content

Instantly share code, notes, and snippets.

@FrankFang
Created March 11, 2018 18:52
Show Gist options
  • Save FrankFang/fca4a98845e38d0c84887a2987132db7 to your computer and use it in GitHub Desktop.
Save FrankFang/fca4a98845e38d0c84887a2987132db7 to your computer and use it in GitHub Desktop.

Exercise 38: Throttle Input

When dealing with user input, there will be times when the user's input is too noisy, and will potentially clog your servers with extraneous requests. We want the ability to throttle the users's input so that if they interacting for one second, then we will get the user input. Let's say for example, the user clicks a button once too many times upon saving and we only want to fire after they've stopped for a second.

seq([1,2,3,,,,,,,4,5,6,,,]).throttleTime(1000 /* ms */) === seq([,,,,,,,3,,,,,,,,,,6,,,]);

In my opinion, it is 'debounce' but not 'throttle'. And I believe the throttled seq is seq([1,,,,,,,,,,,4,,,,,,,,,]);

I am so confused now.

@FrankFang
Copy link
Author

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