• Core
  • Actions
  • watchWebSocketPublicClient

watchWebSocketPublicClient

Action for subscribing to WebSocket PublicClient changes.

import { watchWebSocketPublicClient } from '@wagmi/core'

Usage

By default, the callback will be invoked when the WebSocket Public Client changes.

import { watchWebSocketPublicClient } from '@wagmi/core'
 
const unwatch = watchWebSocketPublicClient(
  {
    chainId: 1,
  },
  (webSocketPublicClient) => console.log(webSocketPublicClient),
)

Return Value

unwatch is a function that can be called to unsubscribe from the WebSocketPublicClient change event.

Configuration

chainId (optional)

Force a specific chain id for the WebSocket Public Client. The wagmi Client's webSocketPublicClient must be set up as a chain-aware function for this to work correctly.

import { watchWebSocketPublicClient } from '@wagmi/core'
 
const unwatch = watchWebSocketPublicClient(
  {
    chainId: 1,
  },
  (webSocketPublicClient) => console.log(webSocketPublicClient),
)