@my-swu/simulator-client / MatchSessionSnapshotPredicate
Type Alias: MatchSessionSnapshotPredicate
MatchSessionSnapshotPredicate = (
snapshot) =>boolean
Defined in: packages/ts-sdk/src/match-session/session-state.ts:68
Predicate used by waitForSnapshot.
Return true when the current or next snapshot is acceptable for the caller.
Example:
ts
import type { MatchSessionSnapshotPredicate } from '@my-swu/simulator-client'
const matchSessionSnapshotPredicate: MatchSessionSnapshotPredicate = matchSnapshot => matchSnapshot.phase === 'action'
console.log(matchSessionSnapshotPredicate)Parameters
snapshot
Example:
ts
import { createSimulatorClient, type MatchSessionSnapshotPredicate } from '@my-swu/simulator-client'
// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
baseUrl: 'http://127.0.0.1:4000',
})
// Public match fetch returns the latest snapshot projection.
const matchSnapshot = await simulatorClient.matches.get('match_123')
const isActionPhase: MatchSessionSnapshotPredicate = snapshot => snapshot.phase === 'action'
console.log(isActionPhase(matchSnapshot))Returns
boolean
Example
ts
import type { MatchSessionSnapshotPredicate } from '@my-swu/simulator-client'
const waitsForAction: MatchSessionSnapshotPredicate =
matchSnapshot => matchSnapshot.phase === 'action'
console.log(waitsForAction)See
https://simulator-sdk.my-swu.com/guide/match-session#waiting-for-state
