MCPcopy
hub / github.com/tldraw/tldraw / push

Method push

packages/sync-core/src/lib/TLSyncClient.ts:849–861  ·  view source on GitHub ↗

Push a change to the server, or stash it locally if we're offline

(change: RecordsDiff<any>)

Source from the content-addressed store, hash-verified

847
848 /** Push a change to the server, or stash it locally if we're offline */
849 private push(change: RecordsDiff<any>) {
850 this.debug('push', change)
851 squashRecordDiffsMutable(this.speculativeChanges, [change])
852 // in offline mode, we only accumulate in speculativeChanges
853 if (!this.isConnectedToRoom) return
854 if (!this.unsentChanges.nextDiff) {
855 this.unsentChanges.nextDiff = { added: {} as any, updated: {} as any, removed: {} as any }
856 }
857 // records are immutable, so sharing their references with `change` is fine — the
858 // squash gives nextDiff its own containers and tuples without deep-cloning records
859 squashRecordDiffsMutable(this.unsentChanges.nextDiff, [change])
860 this.sendUnsentChanges()
861 }
862
863 /** Get the target FPS for network operations based on presence mode */
864 private getSyncFps(): number {

Callers 15

constructorMethod · 0.95
didReconnectMethod · 0.95
maybeCaptureParentFunction · 0.45
computed.test.tsFile · 0.45
helpers.test.tsFile · 0.45
constructorMethod · 0.45
tickMethod · 0.45
errors.test.tsFile · 0.45
history.test.tsFile · 0.45
testReactorFunction · 0.45

Calls 2

debugMethod · 0.95
squashRecordDiffsMutableFunction · 0.90

Tested by 15

constructorMethod · 0.36
tickMethod · 0.36
testReactorFunction · 0.36
testReactorFunction · 0.36
makeStorageFunction · 0.36
runTestFunction · 0.36
sendMessageMethod · 0.36
onReceiveMessageMethod · 0.36
onStatusChangeMethod · 0.36
constructorMethod · 0.36
execFunction · 0.36
constructorMethod · 0.36