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

Method subscribe

client/packages/core/src/SyncTable.ts:481–496  ·  view source on GitHub ↗
(
    q: any,
    cb: SyncTableCallback<any, any, any>,
  )

Source from the content-addressed store, hash-verified

479 }
480
481 public subscribe(
482 q: any,
483 cb: SyncTableCallback<any, any, any>,
484 ): (
485 opts?: { keepSubscription?: boolean | null | undefined } | null | undefined,
486 ) => void {
487 const hash = weakHash(q);
488 this.callbacks[hash] = this.callbacks[hash] || [];
489 this.callbacks[hash].push(cb);
490
491 this.initSubscription(q, hash, cb);
492
493 return (opts?: { keepSubscription?: boolean | null | undefined }) => {
494 this.unsubscribe(hash, cb, opts?.keepSubscription);
495 };
496 }
497
498 private unsubscribe(
499 hash: string,

Callers 3

InstantSuspenseProviderFunction · 0.45
subscribeTableMethod · 0.45
MainFunction · 0.45

Calls 4

initSubscriptionMethod · 0.95
unsubscribeMethod · 0.95
weakHashFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected