UNPKG

@macalinao/grill

Version:

Modern Solana development kit for React applications with automatic account batching, caching, and transaction notifications

32 lines 1.39 kB
import type { Address } from "@solana/kit"; import type { AccountData, AccountDecoder } from "../contexts/subscription-context.js"; /** * Hook to subscribe to account changes via the SubscriptionManager. * * This hook: * - Uses the SubscriptionManager for de-duplicated WebSocket subscriptions * - Only creates one subscription per account address across all components * - Automatically cleans up when all subscribers unmount * - Updates React Query cache when account data changes * * @param address - The account address to subscribe to, or null/undefined to skip * @param decoder - Function to decode the account data (must be stable reference) * @param enabled - Whether the subscription should be active * * @example * ```tsx * function MyComponent() { * const minerPda = useMinerPda({ authority }); * * // Subscribe to account changes * useAccountSubscription(minerPda, decodeMiner, true); * * // Use the standard account hook for data - it gets updated by the subscription * const { data: miner } = useAccount({ address: minerPda, decoder: decodeMiner }); * * return <div>{miner?.data.authority}</div>; * } * ``` */ export declare function useAccountSubscription<T extends AccountData>(address: Address | null | undefined, decoder: AccountDecoder<T> | undefined, enabled: boolean): void; //# sourceMappingURL=use-account-subscription.d.ts.map