UNPKG

alinea

Version:

[![npm](https://img.shields.io/npm/v/alinea.svg)](https://npmjs.org/package/alinea) [![install size](https://packagephobia.com/badge?p=alinea)](https://packagephobia.com/result?p=alinea)

27 lines (25 loc) 581 B
import { atom } from "../../chunks/chunk-OBOPLPUQ.js"; import "../../chunks/chunk-U5RRZUYZ.js"; // src/dashboard/util/DebounceAtom.ts function debounceAtom(readable, delay) { const current = atom(void 0); let timeout; const result = atom( (get, options) => { const next = get(readable); const update = () => options.setSelf(next); clearTimeout(timeout); timeout = setTimeout(update, delay); return get(current) ?? next; }, (get, set, value) => { set(current, value); } ); return result; } export { debounceAtom };