export declare type Subscriber = (state: TState, prev?: TState) => void; export declare type Unsubscriber = () => void; export declare type Updater = ((prev: TState) => TState) | TState; /** * A base construct for a stateful model that is decoupled from its state * implementation. This allows for bindings to a variety of state * implementations e.g. React `useState`, Svelte `writable`, and more. */ export declare abstract class StateModel { #private; initialState: TState; /** * Called by the core model when it **wants** to update state. It is up to * the state implementation to respond to the state update request and * trigger any side-effects e.g. updating the DOM. */ requestStateUpdate?: (updater: Updater) => void; debug: boolean; constructor(initialState: TState); get state(): TState; /** * Update the model's internal state. * * **This should only be called by an external state implementation**. * * Internal state updates should be dispatched via `options.requestStateUpdate`. * * @param newState The new state value. */ setState(newState: TState): void; /** * Subscribe to state changes in the state model. Subscriber instances are * de-duplicated so this method is idempotent. * * @param subscriber The subscriber function. * @returns An unsubscriber function. */ subscribeState(subscriber: Subscriber): Unsubscriber; }