import { StoreContext, EventPayloadMap, StoreConfig, Store, ExtractEvents, Readable, BaseAtom, StoreSnapshot } from "./types.js";
/**
* A React hook that subscribes to the `store` and selects a value from the
* store's snapshot via a selector function, with an optional compare function.
*
* @deprecated Use `useSelector` from `@xstate/store-react` instead.
* @example
*
* ```ts
* function Component() {
* const count = useSelector(store, (s) => s.count);
*
* return
{count}
;
* }
* ```
*
* @param store The store, created from `createStore(…)`
* @param selector A function which takes in the `snapshot` and returns a
* selected value
* @param compare An optional function which compares the selected value to the
* previous value
* @returns The selected value
*/
export declare function useSelector, T>(store: TStore, selector: (snapshot: TStore extends Readable ? T : never) => T, compare?: (a: T | undefined, b: T) => boolean): T;
/**
* A React hook that subscribes to the `store` and selects a value from the
* store's snapshot via an optional selector function (identity by default),
* with an optional compare function.
*
* @example
*
* ```ts
* function Component() {
* const countSnapshot = useSelector(store);
*
* return
{countSnapshot.context.count}
;
* }
* ```
*
* @param store The store, created from `createStore(…)`
* @param selector An optional function which takes in the `snapshot` and
* returns a selected value
* @param compare An optional function which compares the selected value to the
* previous value
* @returns The selected value
*/
export declare function useSelector>(store: TStore, selector?: undefined, compare?: (a: TStore extends Readable ? T : never | undefined, b: TStore extends Readable ? T : never | undefined) => boolean): TStore extends Readable ? T : never;
/** @deprecated Use `useStore` from `@xstate/store-react` instead. */
export declare const useStore: {
(definition: StoreConfig): Store>;
(definition: StoreConfig): Store>;
};
/**
* A React hook that subscribes to the `atom` and returns the current value of
* the atom.
*
* @deprecated Use `useAtom` from `@xstate/store-react` instead.
* @example
*
* ```ts
* const atom = createAtom(0);
*
* const Component = () => {
* const count = useAtom(atom);
*
* return (
*
*
{count}
*
*
* );
* };
* ```
*
* @param atom The atom, created from `createAtom(…)`
* @param selector An optional function which takes in the `snapshot` and
* returns a selected value
* @param compare An optional function which compares the selected value to the
* previous value
*/
export declare function useAtom(atom: BaseAtom): T;
export declare function useAtom(atom: BaseAtom, selector: (snapshot: T) => S, compare?: (a: S, b: S) => boolean): S;
/**
* Creates a custom hook that returns the selected value and the store from a
* store configuration object.
*
* @deprecated Use `createStoreHook` from `@xstate/store-react` instead.
* @example
*
* ```ts
* const useCountStore = createStoreHook({
* context: { count: 0 },
* on: {
* inc: (context, event: { by: number }) => ({
* ...context,
* count: context.count + event.by
* })
* }
* });
*
* function Component() {
* const [count, store] = useCountStore(s => s.context.count);
*
* return (
*
* {count}
*
*
* );
* }
* ```
*
* @param definition The store configuration object
* @returns A custom hook that returns [selectedValue, store]
*/
export declare function createStoreHook(definition: StoreConfig): {
(): [StoreSnapshot, Store>];
(selector: (snapshot: StoreSnapshot) => T, compare?: (a: T | undefined, b: T) => boolean): [T, Store>];
};