-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DebouncedChan: When channel is firing continously, only fire once per…
… period (#222) This one's a follow up to #221. `DebouncedChan` previously had a bit of a bug where if `Call` was being invoked continuously, it was firing more often than expected: once for an initial `Call`, and then again when the timer elapsed. Here, we modify the implementation so that under a continuous fire situation, `DebouncedChan` will fire once initially, and then once every time the timer elapses at the end of each period. This reduces the number of emits on `C` from 2N+1 to the more expected N+1 (the +1 being the initial fire). We accomplish this by entering a loop that waits on the timer when receiving an initial `Call`, with the loop continuously resetting and waiting on the timer after each time it fires, sending on `C` each time the period elapses where a `Call` invocation came in. If a period elapses without a new `Call` coming in, the timer stops, the loop returns and `DebouncedChan` returns to its initial state.
- Loading branch information
Showing
3 changed files
with
49 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters