import { BehaviorSubject, Observable, Subject } from 'rxjs'; type FunctionPatch = (currentValue: T) => T; /** * A value or a function which takes the current value and returns a new value. */ export type Patch = T | FunctionPatch; /** * Gets the current value of an observable, or undefined if the observable has * not emitted a value yet. * * @param observable$ the observable to get the value from. */ export declare const getCurrentValue: (observable$: Observable) => T; /** * Updates the value of the provided Subject. * An `update` can either be a new value or a function which takes * the current value and returns a new value. * * @param subject the subject to update. * @param update the update to apply to the subject. * @return the updated value. */ export declare const setCurrentValue: (subject: Subject, update: Patch) => T; /** * Updates the value of the provided Subject and returns the previous value * and a function to roll back the update. * This is useful when you want to optimistically update a value * and roll back the update if an error occurs. * * @param subject the subject to update. * @param update the update to apply to the subject. */ export declare const updateValue: (subject: BehaviorSubject, update: Patch) => { lastValue: T; value: T; rollback: () => T; }; /** * Creates a subscription and returns a function to unsubscribe. * * @param observable the observable to subscribe to. * @param handler the handler to call when the observable emits a value. * @param onError an optional error handler. */ export declare const createSubscription: (observable: Observable, handler: (value: T) => void, onError?: (error: any) => void) => () => void; /** * Creates a subscription and returns a function to unsubscribe. Makes sure that * only one async handler runs at the same time. If updates come in quicker than * it takes for the current handler to finish, other handlers will wait. * * @param observable the observable to subscribe to. * @param handler the async handler to call when the observable emits a value. */ export declare const createSafeAsyncSubscription: (observable: Observable, handler: (value: T) => Promise) => () => void; export {};