Skip to main content

onGlobalChanges

@zylem/game-lib


@zylem/game-lib / globals / onGlobalChanges

Function: onGlobalChanges()

onGlobalChanges<T>(paths, callback): () => void

Defined in: packages/game-lib/src/lib/game/game-state.ts:92

Subscribe to changes on multiple global paths. Callback fires when any of the paths change, receiving all current values. Subscriptions are automatically cleaned up when the game is disposed.

Type Parameters​

T​

T extends unknown[] = unknown[]

Parameters​

paths​

string[]

callback​

(values) => void

Returns​

() => void

Example​

const unsub = onGlobalChanges(['score', 'lives'], ([score, lives]) => console.log(score, lives));