Sometimes when writing code you need to run a certain function in a loop. However, that function may need to make database calls or do some other sort of expensive computation. To prevent that call from happening you can debounce the function or essentially limit how often it runs. Today's goal is to create a debouncer that only lets a function run at most 4 times per second. The functionality should be similar to this:
count = 0; while(true) { debounce(function() { count++; }, 250); }
Comments:
Anonymous - 10 years, 1 month ago
C# with simple console app to test results
reply permalink