import { ParentCache } from "./ParentCache.js"; import { ItemCleanupPair } from "@isograph/disposable-types"; //#region src/useCachedResponsivePrecommitValue.d.ts /** * useCachedResponsivePrecommitValue * - Takes a mutable parent cache, a factory function, and an onCommit callback. * - Returns T before commit after every parent cache change, and null afterward. * - Calls onCommit with the ItemCleanupPair during commit after every parent cache change. * - The T from the render phase is only temporarily retained. It may have been * disposed by the time of the commit. If so, this hook checks the parent cache * for another T or creates one, and passes this T to onCommit. * - If the T returned during the last render is not the same as the one that * is passed to onCommit, during the commit phase, it will schedule another render. * * Invariant: the returned T has not been disposed during the tick of the render. * The T passed to the onCommit callback has not been disposed when the onCommit * callback is called. * * Passing a different parentCache: * - Pre-commit, passing a different parentCache has the effect of "resetting" this * hook's state to the new cache's state. For example, if you have a cache associated * with a set of variables (e.g. {name: "Matthew"}), and pass in another cache * (e.g. associated with {name: "James"}), which is empty, the hook will fill that * new cache with the factory function. * - Post-commit, passing a different parentCache will reset hook to the pre-commit * state. The cache will return T before commit, then fill the new cache with the * factory function and return null afterwards. * * Passing a different factory: * - Passing a different factory has no effect, except when factory is called, * which is when the parent cache is being filled, or during commit. * * Passing a different onCommit: * - Passing a different onCommit has no effect, except for during commit. */ declare function useCachedResponsivePrecommitValue(parentCache: ParentCache, onCommit: (pair: ItemCleanupPair) => void): { state: T; } | null; //#endregion export { useCachedResponsivePrecommitValue }; //# sourceMappingURL=useCachedResponsivePrecommitValue.d.ts.map