import { Data } from './types.js'; import { Model, Props, Actions, UseActions } from '../types/index.js'; /** * A hook for managing state with actions. * * Call `useActions` first, then use `actions.useAction` to bind handlers * to action symbols. Types are pre-baked from the generic parameters, so * no additional type annotations are needed on handler calls. * * The hook returns a result containing: * 1. The current model state * 2. An actions object with `dispatch`, `inspect`, and `useAction` * 3. A read-only snapshot of the data values produced by `getData` — * the same values handlers read via `context.data`, exposed here for * JSX consumption so the view and the handler share one named source. * * The `inspect` property provides access to Immertation's annotation system, * allowing you to check for pending operations on model properties. * * @template M The model type representing the component's state. * @template AC The actions class containing action definitions. * @template D The data type for reactive external values. * @param model The initial model state. * @param getData Optional function that returns reactive values as data. * Values returned are accessible via `context.data` in action handlers, * always reflecting the latest values even after await operations. * @returns A result `[model, actions, data]` with pre-typed `useAction` method. * * @example * ```typescript * // Basic usage * const [model, actions] = useActions(model); * * // Without a model (actions-only) * const [, actions] = useActions(); * * // With reactive data — consumed in JSX and handlers alike. * const [model, actions, data] = useActions< * Model, * typeof Actions, * { query: string } * >(model, () => ({ query: props.query })); * ``` */ export declare function useActions(getData?: Data): UseActions; export declare function useActions(model: M, getData?: Data): UseActions;