MCPcopy Index your code
hub / github.com/apache/pouchdb / onChangesComplete

Function onChangesComplete

lib/index.js:10104–10148  ·  view source on GitHub ↗
(changes)

Source from the content-addressed store, hash-verified

10102
10103
10104 function onChangesComplete(changes) {
10105 changesPending = false;
10106 /* istanbul ignore if */
10107 if (returnValue.cancelled) {
10108 return completeReplication();
10109 }
10110
10111 // if no results were returned then we're done,
10112 // else fetch more
10113 if (changes.results.length > 0) {
10114 changesOpts.since = changes.results[changes.results.length - 1].seq;
10115 getChanges();
10116 processPendingBatch(true);
10117 } else {
10118
10119 var complete = function () {
10120 if (continuous) {
10121 changesOpts.live = true;
10122 getChanges();
10123 } else {
10124 changesCompleted = true;
10125 }
10126 processPendingBatch(true);
10127 };
10128
10129 // update the checkpoint so we start from the right seq next time
10130 if (!currentBatch && changes.results.length === 0) {
10131 writingCheckpoint = true;
10132 checkpointer.writeCheckpoint(changes.last_seq,
10133 session).then(function () {
10134 writingCheckpoint = false;
10135 result.last_seq = last_seq = changes.last_seq;
10136 if (returnValue.cancelled) {
10137 completeReplication();
10138 throw new Error('cancelled');
10139 } else {
10140 complete();
10141 }
10142 })
10143 .catch(onCheckpointError);
10144 } else {
10145 complete();
10146 }
10147 }
10148 }
10149
10150
10151 function onChangesError(err) {

Callers

nothing calls this directly

Calls 5

completeReplicationFunction · 0.70
getChangesFunction · 0.70
processPendingBatchFunction · 0.70
completeFunction · 0.70
writeCheckpointMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…