Skip to content

@my-swu/simulator-client


@my-swu/simulator-client / SimulatorRequestOptions

Interface: SimulatorRequestOptions ​

Defined in: packages/ts-sdk/src/http/options.ts:28

Per-call cancellation controls accepted by every SDK HTTP method.

Pass this as the last argument of any resource method. Omit it and the call behaves exactly as it did before cancellation existed, apart from a client-level timeoutMs when one is configured on createSimulatorClient.

signal and timeoutMs compose: whichever fires first cancels the request, and the rejected EngineRequestAbortedError names which one it was.

Example:

ts
import type { SimulatorRequestOptions } from '@my-swu/simulator-client'

const simulatorRequestOptions: SimulatorRequestOptions = {}

console.log(simulatorRequestOptions)

Example ​

ts
import { createSimulatorClient, type SimulatorRequestOptions } from '@my-swu/simulator-client'

const simulatorClient = createSimulatorClient({ baseUrl: 'http://127.0.0.1:4000' })
const unmountController = new AbortController()
const cancellation: SimulatorRequestOptions = {
  signal: unmountController.signal,
  timeoutMs: 5_000,
}

const publicMatchSnapshot = await simulatorClient.matches.get('match_123', cancellation)
console.log(publicMatchSnapshot.phase)

See ​

https://simulator-sdk.my-swu.com/guide/http-client#cancellation-and-timeouts

Properties ​

signal? ​

Example:

ts
import type { SimulatorRequestOptions } from '@my-swu/simulator-client'

const simulatorRequestOptions: SimulatorRequestOptions = {}

const { signal } = simulatorRequestOptions

console.log(signal)

optional signal?: AbortSignal

Defined in: packages/ts-sdk/src/http/options.ts:32

Caller-owned signal that cancels the request when it aborts.


timeoutMs? ​

Example:

ts
import type { SimulatorRequestOptions } from '@my-swu/simulator-client'

const simulatorRequestOptions: SimulatorRequestOptions = {}

const { timeoutMs } = simulatorRequestOptions

console.log(timeoutMs)

optional timeoutMs?: number

Defined in: packages/ts-sdk/src/http/options.ts:39

Milliseconds to wait before the SDK cancels the request itself.

Overrides the client-level timeoutMs. Pass 0 to opt one call out of a client-level default.

Released under the MIT License.