Class Scheduler
java.lang.Object
org.jboss.elemento.Scheduler
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CallbackExecutes the given callback after a specified timeout.static <T> Consumer<T> debounceValue(int timeout, Consumer<T> consumer) Executes the given consumer after a specified timeout, passing the most recent value.
-
Constructor Details
-
Scheduler
public Scheduler()
-
-
Method Details
-
debounce
Executes the given callback after a specified timeout. If this method is called multiple times within the specified timeout period, the original callback will only be executed once at the end of the timeout.- Parameters:
timeout- The timeout value in milliseconds.callback- The callback function to execute.- Returns:
- A new callback function that debounces the original callback.
-
debounceValue
Executes the given consumer after a specified timeout, passing the most recent value. If the returned consumer is called multiple times within the specified timeout period, only the last value will be passed to the original consumer once at the end of the timeout.- Type Parameters:
T- the type of the input to the consumer- Parameters:
timeout- The timeout value in milliseconds.consumer- The consumer function to execute with the most recent value.- Returns:
- A new consumer that debounces the original consumer.
-