import { BaseSubscribable } from "../../subscribable/subscribable.js";
type Transform<TState, TResult> = {
    execute: () => Promise<TResult>;
    /** transform the state after the promise resolves */
    then?: (state: TState, result: TResult) => TState;
    /** transform the state during resolution and afterwards */
    optimistic?: (state: TState) => TState;
    /** transform the state only while loading */
    loading?: (state: TState, task: Promise<TResult>) => TState;
};
export declare class OptimisticState<TState> extends BaseSubscribable {
    private readonly _pendingTransforms;
    /**
     * `optimistic` callbacks from transforms that have already resolved.
     * Re-applied after every `then` callback so that a wholesale state
     * replacement (e.g. list()) cannot erase earlier completed effects
     * (e.g. delete). Cleared when no pending transforms remain.
     *
     * Correctness requirement: `optimistic` callbacks must be idempotent.
     */
    private readonly _completedOptimistics;
    private _baseValue;
    private _cachedValue;
    constructor(initialState: TState);
    private _updateState;
    get baseValue(): TState;
    get value(): TState;
    update(state: TState): void;
    optimisticUpdate<TResult>(transform: Transform<TState, TResult>): Promise<TResult>;
}
export {};
//# sourceMappingURL=optimistic-state.d.ts.map