withSignal
withSignal<
transport>(transport,signal):transport
Defined in: packages/synapse-core/src/utils/abort.ts:87
Wrap a viem transport so its requests reject with iso-web’s AbortError once the signal aborts.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Description |
|---|---|
transport extends Transport |
The transport to wrap. |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
transport |
transport |
- |
signal |
AbortSignal | undefined |
The signal to abort requests. The transport is returned as is when undefined. |
Returns
Section titled “Returns”transport
The wrapped transport.
Example
Section titled “Example”import { createPublicClient, http } from 'viem'
import { calibration } from '@filoz/synapse-core/chains'
import { withSignal } from '@filoz/synapse-core/utils'
const controller = new AbortController()
const client = createPublicClient({
chain: calibration,
transport: withSignal(http('https://my-rpc.example.com'), controller.signal),
})