<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>lodash.debounce</artifactId>
<version>4.0.8</version>
</dependency>
import static jsinterop.annotations.JsPackage.GLOBAL;
import jsinterop.annotations.JsFunction;
import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsType;
import jsinterop.base.JsPropertyMap;
import jsinterop.base.JsVoidPromise;
@JsType(isNative = true, namespace = GLOBAL, name = "lodash.debounce")
public class LodashDebounce {
@JsFunction
public interface DebouncedFunction {
void apply();
}
@JsMethod
public static native DebouncedFunction debounce(DebouncedFunction fn, int delay);
}
public class Main {
public static void main(String[] args) {
LodashDebounce.DebouncedFunction debouncedFunction = LodashDebounce.debounce(() -> {
System.out.println("Function called!");
}, 2000);
debouncedFunction.apply();
debouncedFunction.apply();
debouncedFunction.apply();
}
}