| 376 | indexes.dirty.subscribe(printDebugRecords); |
| 377 | |
| 378 | function 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 | |
| 404 | subscribeToTagDiff("editor", (inserts, removes, records) => { |
| 405 | if(!client.showIDE) return; |