Package net.bluemind.lib.vertx.utils
Class Debouncer<P>
java.lang.Object
net.bluemind.lib.vertx.utils.Debouncer<P>
Block calls to the given
BiConsumer
in a debounce way. Allow
the last call to be executed after a grace period (interval
). Each
call is identified using KEY
. Only calls sharing the same
identity block each others. Thread safe.-
Constructor Summary
-
Method Summary
-
Constructor Details
-
Debouncer
- Parameters:
consumer
- the code to execute in a debounce wayinterval
- the debounce grace period in millisecondsnoDebounceFirst
- the very first call (per key) will not suffer the grace period. It violates the real debounce pattern but may be useful in some cases.
-
-
Method Details
-
call
Request a call toconsumer
, based on the givenkey
. The actual execution of the code depends on the debounce grace period: if no call with that key has been done withininterval
milliseconds then execute the last call.
-