UNPKG

melt

Version:

The next generation of Melt UI. Built for Svelte 5.

36 lines (35 loc) 1.09 kB
import type { MaybeGetter } from "./types"; type EqualityCheck<T> = boolean | ((prev: T, next: T) => boolean); type SyncedArgsBase<T> = { onChange?: (value: T) => void; /** * Optional equality check function. If this is set to true, * the `===` operator will be used. * * If it's a function and returns true, no changes will occur. */ equalityCheck?: EqualityCheck<T>; }; type SyncedArgs<T> = SyncedArgsBase<T> & ({ value: MaybeGetter<T>; defaultValue?: never; } | { value: MaybeGetter<T | undefined>; defaultValue: T; }); /** * Setting `current` calls the `onChange` callback with the new value. * * If the value arg is static, it will be used as the default value, * and subsequent sets will set an internal state that gets read as `current`. * * Otherwise, if it is a getter, it will be called every time `current` is read, * and no internal state is used. */ export declare class Synced<T> { #private; constructor({ value, onChange, ...args }: SyncedArgs<T>); get current(): T; set current(value: T); } export {};