watchConnections ​
Subscribe to connections changes.
Import ​
ts
import { watchConnections } from '@wagmi/core'
import { watchConnections } from '@wagmi/core'
Usage ​
ts
import { watchConnections } from '@wagmi/core'
import { config } from './config'
const unwatch = watchConnections(config, {
onChange(data) {
console.log('Connections changed!', data)
},
})
unwatch()
import { watchConnections } from '@wagmi/core'
import { config } from './config'
const unwatch = watchConnections(config, {
onChange(data) {
console.log('Connections changed!', data)
},
})
unwatch()
ts
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
Parameters ​
ts
import { type WatchConnectionsParameters } from '@wagmi/core'
import { type WatchConnectionsParameters } from '@wagmi/core'
onChange ​
onChange(connections: GetConnectionsReturnType, prevConnections: GetConnectionsReturnType): void
Callback function called when connections changes.
ts
import { watchConnections } from '@wagmi/core'
import { config } from './config'
const unwatch = watchConnections(config, {
onChange(data) {
console.log('Connections changed!', data)
},
})
unwatch()
import { watchConnections } from '@wagmi/core'
import { config } from './config'
const unwatch = watchConnections(config, {
onChange(data) {
console.log('Connections changed!', data)
},
})
unwatch()
ts
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
Return Type ​
ts
import { type WatchConnectionsReturnType } from '@wagmi/core'
import { type WatchConnectionsReturnType } from '@wagmi/core'
Function for cleaning up watcher.