Skip to main content

SharedObservableOptions<T>

Defined in: src/lib/observable/shared.ts:29

Options for shared observables with conflict resolution.

Extends

Type Parameters

Type Parameter
T

Properties

PropertyTypeDescriptionInherited fromDefined in
broadcast?booleanIf true, all connected players are automatically subscribed. If false (default), players must be manually subscribed. Default falseObservableOptions.broadcastsrc/lib/observable/types.ts:63
conflictResolution?| "last-write-wins" | "server-wins" | "client-wins" | ConflictResolver<T>Conflict resolution strategy. - "last-write-wins": Latest timestamp wins (default) - "server-wins": Server always overrides client - "client-wins": Client always overrides server - custom function: (serverValue, clientValue, serverTimestamp, clientTimestamp) => resolvedValue Default "last-write-wins"-src/lib/observable/shared.ts:39
equals?(a: T, b: T) => booleanCustom equality function to determine if value has changed. Defaults to strict equality (===).SyncedObservableOptions.equalssrc/lib/observable/types.ts:73
idstringUnique identifier for this observable. Used for RPC event naming and debugging. Format: "moduleName:observableName"ObservableOptions.idsrc/lib/observable/types.ts:50
initialValueTInitial value of the observable.SyncedObservableOptions.initialValuesrc/lib/observable/types.ts:55
noResponse?booleanIf true, use fire-and-forget mode for sync updates. Faster but no guarantee of delivery. Default trueSyncedObservableOptions.noResponsesrc/lib/observable/types.ts:257
perPlayer?booleanIf true, this observable is per-player (each player has their own value). - On server: Multiple instances can exist with the same base ID. Use subscribePlayer(playerId) to subscribe and sync to a specific player. - On client: The observable automatically receives values sent to this client. No need to know the player's server ID. The sync event name uses the base ID (without player ID suffix), and FiveM's emitNet targets the specific player. Default falseSyncedObservableOptions.perPlayersrc/lib/observable/types.ts:272
syncDebounceMs?numberDebounce sync updates by this many milliseconds. Useful for frequently changing values. Default 0 (no debounce)ObservableOptions.syncDebounceMssrc/lib/observable/types.ts:81