rvx
Version:
A signal based rendering library
16 lines • 548 B
JavaScript
import { teardown } from "../core/lifecycle.js";
import { $, watchUpdates } from "../core/signals.js";
export function debounce(source, delay) {
const input = $(source.value, source);
watchUpdates(input, value => {
if (!Object.is(source.value, value)) {
const timeout = setTimeout(() => { source.value = value; }, delay);
teardown(() => clearTimeout(timeout));
}
});
watchUpdates(source, value => {
input.value = value;
});
return input;
}
//# sourceMappingURL=debounce.js.map