MCPcopy Create free account
hub / github.com/instantdb/instant / onSyncInitFinish

Method onSyncInitFinish

client/packages/core/src/SyncTable.ts:694–724  ·  view source on GitHub ↗
(msg: SyncInitFinishMsg)

Source from the content-addressed store, hash-verified

692 }
693
694 public onSyncInitFinish(msg: SyncInitFinishMsg) {
695 const subscriptionId = msg['subscription-id'];
696 const hash = this.idToHash[subscriptionId];
697 if (!hash) {
698 this.log.error('Missing hash for subscription', msg);
699 return;
700 }
701 this.subs.updateInPlace((prev) => {
702 const sub = prev[hash];
703 if (!sub) {
704 this.log.error('Missing sub for hash', hash, msg);
705 return;
706 }
707 const state = sub.state;
708 if (!state) {
709 this.log.error('Sub never set init, missing result', sub, msg);
710 return prev;
711 }
712 state.txId = msg['tx-id'];
713 sub.updatedAt = Date.now();
714 });
715
716 const sub = this.subs.currentValue[hash];
717
718 if (sub) {
719 this.notifyCbs(hash, {
720 type: CallbackEventType.InitialSyncComplete,
721 data: subData(sub, sub.values?.entities || []),
722 });
723 }
724 }
725
726 public onSyncUpdateTriples(msg: SyncUpdateTriplesMsg) {
727 const subscriptionId = msg['subscription-id'];

Callers 1

_handleReceiveMethod · 0.80

Calls 4

notifyCbsMethod · 0.95
subDataFunction · 0.85
updateInPlaceMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected