MCPcopy Index your code
hub / github.com/DeepNotesApp/DeepNotes / _subscribe

Method _subscribe

apps/client/src/code/realtime/context.ts:101–126  ·  view source on GitHub ↗
(prefix: DataPrefix, suffix: string, field: string)

Source from the content-addressed store, hash-verified

99 }
100
101 private _subscribe(prefix: DataPrefix, suffix: string, field: string) {
102 const fullKey = getFullKey(prefix, suffix, field);
103
104 if (this.subscriptions.has(fullKey)) {
105 return;
106 }
107
108 this._logger.sub('subscribe').info(fullKey);
109
110 this.subscriptions.add(fullKey);
111
112 if (!internals.realtime.isSynced(prefix as any, suffix, field)) {
113 internals.realtime.pending.set(fullKey, new Resolvable());
114 this.pending.add(fullKey);
115 }
116
117 internals.realtime.subscriptions[fullKey] ??= new Set();
118 internals.realtime.subscriptions[fullKey].add(this);
119
120 if (internals.realtime.subscriptions[fullKey].size === 1) {
121 internals.realtime.pushCommand({
122 type: RealtimeCommandType.SUBSCRIBE,
123 args: [prefix, suffix, field],
124 });
125 }
126 }
127 unsubscribe(prefix: DataPrefix, suffix: string, field: string) {
128 const fullKey = getFullKey(prefix, suffix, field);
129

Callers 2

hgetAsyncMethod · 0.80
hgetMethod · 0.80

Calls 7

getFullKeyFunction · 0.90
subMethod · 0.80
isSyncedMethod · 0.80
pushCommandMethod · 0.80
setMethod · 0.65
hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected