seitu
Version:
25 lines • 916 B
text/typescript
import { i as Subscribable, n as Readable } from "./index-B0IeflOl.mjs";
//#region src/core/debounced/index.d.ts
interface Debounced<T> extends Readable<T>, Subscribable<T> {
/** Drop a pending update. The current value is unchanged. */
cancel: () => void;
/** Emit a pending update now. No-op if nothing is pending. */
flush: () => void;
}
/**
* Debounces updates from a source. Unsubscribed `get()` reads through;
* subscribed `get()` returns the last emitted value.
*
* @example
* ```ts twoslash
* import { createStore, createDebounced } from 'seitu'
*
* const store = createStore('')
* const debounced = createDebounced(store, 300)
* debounced.subscribe(value => console.log('debounced:', value))
* debounced.flush()
* ```
*/
declare function createDebounced<T>(source: Readable<T> & Subscribable<T>, wait: number): Debounced<T>;
//#endregion
export { createDebounced as n, Debounced as t };