import { ReadOnlyAtomInterface } from './Atom'; import { Store } from './Store'; import { StoreConstructable, StoreProxy } from './types'; /** * Provides access to a Nucleux store instance. * * This hook retrieves a store instance from the container and ensures proper * cleanup when the component unmounts. * * @template S - The store type that extends the base Store class * @param {StoreConstructable} store - The store class constructor * @returns {S} The store instance * * @example * // Define your store * class CounterStore extends Store { * count = this.atom(0); * * increment() { * this.count.value++; * } * } * * // Use the store in a component * function Counter() { * const counterStore = useStore(CounterStore); * const count = useValue(counterStore.count); * * return ( *
*

Count: {count}

* *
* ); * } */ declare function useStore(store: StoreConstructable): S; /** * Subscribes to an atom's value and returns the current value. * * This hook creates a subscription to an atom and triggers re-renders * when the atom's value changes. * * @template V - The type of the atom's value * @param {ReadOnlyAtomInterface} atom - The atom to subscribe to * @returns {V} The current value of the atom * * @example * // Using with an atom directly * const userStore = useStore(UserStore); * const username = useValue(userStore.username); */ declare function useValue(atom: ReadOnlyAtomInterface): V; /** * Directly accesses an atom value from a store by key name. * * This overload allows accessing a specific atom from a store without * explicitly retrieving the store instance first. * * @template S - The store type that extends the base Store class * @template K - The key of the atom in the store * @param {StoreConstructable} store - The store class constructor * @param {K} atomKey - The key of the atom to access * @returns {S[K] extends AtomInterface ? V : never} The current value of the atom * * @example * // Direct access to an atom value * const username = useValue(UserStore, "username"); * const isLoggedIn = useValue(UserStore, "isLoggedIn"); */ declare function useValue(store: StoreConstructable, atomKey: K): S[K] extends ReadOnlyAtomInterface ? V : never; /** * Provides access to all methods and state values from a Nucleux store in a single hook. * * This hook creates a reactive proxy to the store that automatically updates when any atom * in the store changes. It's designed for components that need access to multiple atoms * from the same store without having to use multiple hooks. * * @template S - The store type that extends the base Store class * @param {StoreConstructable} store - The store class constructor * @returns {StoreProxy} A proxy object containing both store methods and atom values * * @example * // Define your store * class CounterStore extends Store { * count = this.atom(0); * * increment() { * this.count.value++; * } * * decrement() { * this.count.value--; * } * } * * // Use the store in a component * function Counter() { * const counter = useNucleux(CounterStore); * * // Access both methods and state directly * return ( *
*

Count: {counter.count}

* * *
* ); * } * * @remarks * - This hook subscribes to all atoms in the store, so components will re-render on any state change. * - For more selective reactivity, consider using `useStore` with individual `useValue` hooks instead. * - Cannot directly modify atom values through the proxy; use store methods for state updates. */ declare function useNucleux(store: StoreConstructable): StoreProxy; export { useNucleux, useStore, useValue };