MCPcopy
hub / github.com/apache/pouchdb / onChange

Function onChange

lib/index.js:10073–10101  ·  view source on GitHub ↗
(change, pending, lastSeq)

Source from the content-addressed store, hash-verified

10071 }
10072
10073 function onChange(change, pending, lastSeq) {
10074 /* istanbul ignore if */
10075 if (returnValue.cancelled) {
10076 return completeReplication();
10077 }
10078 // Attach 'pending' property if server supports it (CouchDB 2.0+)
10079 /* istanbul ignore if */
10080 if (typeof pending === 'number') {
10081 pendingBatch.pending = pending;
10082 }
10083
10084 var filter = filterChange(opts)(change);
10085 if (!filter) {
10086 // update processed items count by 1
10087 var task = src.activeTasks.get(taskId);
10088 if (task) {
10089 // we can assume that task exists here? shouldn't be deleted by here.
10090 var completed = task.completed_items || 0;
10091 src.activeTasks.update(taskId, {completed_items: ++completed});
10092 }
10093 return;
10094 }
10095 pendingBatch.seq = change.seq || lastSeq;
10096 pendingBatch.changes.push(change);
10097 returnValue.emit('checkpoint', { 'pending_batch': pendingBatch.seq });
10098 nextTick(function () {
10099 processPendingBatch(batches.length === 0 && changesOpts.live);
10100 });
10101 }
10102
10103
10104 function onChangesComplete(changes) {

Callers

nothing calls this directly

Calls 5

completeReplicationFunction · 0.70
filterChangeFunction · 0.70
processPendingBatchFunction · 0.70
getMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…