import type { Disposer } from '@zajno/common/functions/disposer'; import { Lazy, type ILazyPromiseExtension, type LazyFactory } from '@zajno/common/lazy'; import { LazyPromise } from '@zajno/common/lazy/promise'; import { ObservableTypes } from '../observing/types.js'; export declare class LazyObservable extends Lazy { constructor(factory: (() => T), observableType?: ObservableTypes); } export type LazyPromiseObservableConfig = { observableType?: ObservableTypes; initial?: TInitial; observing?: boolean | ObserveFactoryOptions; }; export declare class LazyPromiseObservable extends LazyPromise { constructor(factory: LazyFactory, observableType?: ObservableTypes, initial?: TInitial); constructor(factory: LazyFactory, options?: LazyPromiseObservableConfig); } /** * Options for creating an observing extension. */ export type ObserveFactoryOptions = { /** Function that accesses observables to track. Called synchronously before factory execution. */ track?: () => unknown; /** Optional disposer to register the reaction cleanup. */ disposer?: Disposer; }; /** * Creates an extension that automatically refreshes LazyPromise when tracked observables change. * * Dependencies are tracked during factory execution. When any tracked observable changes, * the LazyPromise will automatically call `refresh()` to reload the data. * * @param options - Configuration for tracking and disposal * @returns Extension that adds automatic refresh on dependency changes * * @example * ```typescript * const userStore = observable({ userId: 1 }); * * const userLazy = new LazyPromiseObservable(() => fetchUser(userStore.userId)) * .extend(createObservingExtension({ * track: () => userStore.userId, * })); * * // When userStore.userId changes, userLazy automatically refreshes * ``` */ export declare function createObservingExtension(options?: ObserveFactoryOptions): ILazyPromiseExtension;