MCPcopy
hub / github.com/witheve/Eve / subscribeToTagDiff

Function subscribeToTagDiff

src/client.ts:378–402  ·  view source on GitHub ↗
(tag:string, callback: (inserts: string[], removes: string[], records: {[recordId:string]: any}) => void)

Source from the content-addressed store, hash-verified

376indexes.dirty.subscribe(printDebugRecords);
377
378function subscribeToTagDiff(tag:string, callback: (inserts: string[], removes: string[], records: {[recordId:string]: any}) => void) {
379 indexes.dirty.subscribe((index, dirty) => {
380 let records = {};
381 let inserts = [];
382 let removes = [];
383
384 let dirtyOldRecords = indexes.byTag.dirty[tag] || [];
385 for(let recordId of dirtyOldRecords) {
386 let record = indexes.records.index[recordId];
387 if(!record || !record.tag || record.tag.indexOf(tag) === -1) {
388 removes.push(recordId);
389 }
390 }
391
392 for(let recordId in dirty) {
393 let record = indexes.records.index[recordId];
394 if(record.tag && record.tag.indexOf(tag) !== -1) {
395 inserts.push(recordId);
396 records[recordId] = record;
397 }
398 }
399
400 callback(inserts, removes, records);
401 });
402}
403
404subscribeToTagDiff("editor", (inserts, removes, records) => {
405 if(!client.showIDE) return;

Callers 1

client.tsFile · 0.85

Calls 1

subscribeMethod · 0.80

Tested by

no test coverage detected