import type { VanillaStore } from "../../vanilla/index.cjs"; import type { SnapshotOptions } from "../use-snapshot.cjs"; import type { WithDerivedContributes } from "../../vanilla/enhancers/with-derived.cjs"; export interface WithUseDerivedContributes extends WithDerivedContributes { /** * Get the derived state. */ useDerived: (options?: SnapshotOptions) => Derived; } /** * Enhances a store with `useDerived` & `derived` method that returns the derived state. * * @param store - The store to enhance. * @param mapFn - The function to map the state to the derived state. * @returns The enhanced store. * * @since 0.2.0 * * @example * * ```tsx * const store = withDerived( * create({ * count: 123, * info: { name: 'Viki' }, * }), * (s) => ({ * isViki: s.info.name === 'Viki', * isNegative: s.count < 0, * }), * ) * // in normal JS/TS * console.log(store.derived().isViki) * // in React component * export function App() { * const { isNegative } = store.useDerived() * } * ``` */ export declare function withUseDerived, Derived extends object = Store['mutate']>(store: Store, mapFn?: (state: Store['mutate']) => Derived): Store & WithUseDerivedContributes; //# sourceMappingURL=with-use-derived.d.cts.map