@my-swu/simulator-client / isStaleLobbySnapshot
Function: isStaleLobbySnapshot()
isStaleLobbySnapshot(
current,incoming):boolean
Defined in: packages/ts-sdk/src/resources/lobby-snapshot.ts:26
Reports whether incoming is older than the snapshot already held.
Lobby snapshots arrive over two paths — the lobby socket and the snapshot embedded in every HTTP access response — and the two can race. Every persisted lobby change increases revision, so a lower revision is stale and must not replace newer state. Equal revisions are accepted (live connected flags may differ within one revision), and a snapshot without a revision (older server) is never treated as stale.
Example:
ts
import { isStaleLobbySnapshot } from '@my-swu/simulator-client'
import type { LobbySnapshot } from '@my-swu/simulator-client'
export function keepNewestLobbySnapshot(
current: LobbySnapshot | undefined,
incoming: LobbySnapshot,
) {
return isStaleLobbySnapshot(current, incoming) ? current : incoming
}Parameters
current
Example:
ts
import { isStaleLobbySnapshot } from '@my-swu/simulator-client'
import type { LobbySnapshot } from '@my-swu/simulator-client'
export function keepNewestLobbySnapshot(
current: LobbySnapshot | undefined,
incoming: LobbySnapshot,
) {
return isStaleLobbySnapshot(current, incoming) ? current : incoming
}LobbySnapshot | undefined
incoming
Example:
ts
import { isStaleLobbySnapshot } from '@my-swu/simulator-client'
import type { LobbySnapshot } from '@my-swu/simulator-client'
export function keepNewestLobbySnapshot(
current: LobbySnapshot | undefined,
incoming: LobbySnapshot,
) {
return isStaleLobbySnapshot(current, incoming) ? current : incoming
}Returns
boolean
Example
ts
import { isStaleLobbySnapshot } from '@my-swu/simulator-client'
import type { LobbySnapshot } from '@my-swu/simulator-client'
export function keepNewestLobbySnapshot(
current: LobbySnapshot | undefined,
incoming: LobbySnapshot,
) {
return isStaleLobbySnapshot(current, incoming) ? current : incoming
}