Debounce operator for Callbag
npm i callbag-debounce
Debounces the scroll
event and runs the expensiveFunction
only when there is a 60ms pause.
const { fromEvent, forEach, pipe } = require("callbag-basics");
import { debounce } from "callbag-debounce";
pipe(
fromEvent(document, "scroll"),
debounce(60),
forEach(expensiveFunction)
);
error
(t === 2 && d !== undefined
) signals are sent right away (previously they were delayed according to thewait
parameter);complete
(t === 2 && d === undefined
) signals are sent when the last value is debounced (previously they were debounced according to thewait
parameter).
codebase migrated to TypeScript. The module needs to be imported via a named import
import { debounce } from "callbag-debounce";
previously
import debounce from "callbag-debounce";