/** * memoizedFn — Simple argument memoization without MobX. * * Replaces computedFnDeepCompare for query functions. * With lazy subscribe (SubscribableArray), there's no urgency to clean up * cached entries — unsubscribed entries are just plain arrays in memory. * * refCountedMemoizedFn — Ref-counted memoization for reactive results. * Returns a wrapper that increments a ref count on each call and decrements * on dispose(). When refCount hits 0, the entry is cleaned up (with optional * grace period). */ interface MemoizedFnOptions { argsEqual?: (a: any[], b: any[]) => boolean; argsDebugName?: (...args: any[]) => string; /** Max cache entries. Oldest evicted when exceeded. Default: unlimited. */ maxSize?: number; } export declare function memoizedFn any>(name: string, fn: T, opts?: MemoizedFnOptions): T; /** A result wrapper returned by refCountedMemoizedFn. Call release() when done. */ export interface RefCounted { readonly value: T; /** Decrement ref count. When it reaches 0, the cache entry is cleaned up. */ release(): void; } interface RefCountedOptions any> { argsEqual?: (a: any[], b: any[]) => boolean; argsDebugName?: (...args: any[]) => string; /** * Called when the last reference is released and the entry is evicted. * Use to tear down subscriptions, dispose SubscribableArrays, etc. */ onCleanup?: (result: ReturnType, ...args: Parameters) => void; /** * Grace period in ms before actually cleaning up after refCount hits 0. * If someone re-acquires within this window, the entry is reused. * Default: 0 (immediate cleanup). */ gracePeriodMs?: number; } /** * Creates a memoized function whose results are ref-counted. * * Currently unused — doesn't fit liveQuery's recursive multi-step structure * (API break, cache loss on pattern change without grace period). * See todo/2026-04-17_ciao-mobx/memoized-cache-cleanup.md for full analysis. * * Each call returns `RefCounted>`. Multiple calls with the same * args return the same cached result with an incremented ref count. * When all holders call `release()`, the cache entry is cleaned up * (subject to optional grace period). * * Usage: * ``` * const getFiltered = refCountedMemoizedFn('rollingFilter', (thread, pattern) => { * // ... expensive setup, returns MappedThread * }, { onCleanup: (result) => result.dispose() }) * * const ref = getFiltered(myThread, myPattern) * // use ref.value (the MappedThread) * ref.release() // decrement; when last holder releases, onCleanup fires * ``` */ export declare function refCountedMemoizedFn any>(name: string, fn: T, opts?: RefCountedOptions): (...args: Parameters) => RefCounted>; export {}; //# sourceMappingURL=memoized.d.ts.map