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

Method eventFunction

lib/index.js:365–394  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

363 var inprogress = false;
364 var self = this;
365 function eventFunction() {
366 if (!self._listeners[id]) {
367 return;
368 }
369 if (inprogress) {
370 inprogress = 'waiting';
371 return;
372 }
373 inprogress = true;
374 var changesOpts = pick(opts, [
375 'style', 'include_docs', 'attachments', 'conflicts', 'filter',
376 'doc_ids', 'view', 'since', 'query_params', 'binary', 'return_docs'
377 ]);
378
379 function onError() {
380 inprogress = false;
381 }
382
383 db.changes(changesOpts).on('change', function (c) {
384 if (c.seq > opts.since && !opts.cancelled) {
385 opts.since = c.seq;
386 opts.onChange(c);
387 }
388 }).on('complete', function () {
389 if (inprogress === 'waiting') {
390 nextTick(eventFunction);
391 }
392 inprogress = false;
393 }).on('error', onError);
394 }
395 this._listeners[id] = eventFunction;
396 this.on(dbName, eventFunction);
397 }

Callers

nothing calls this directly

Calls 3

pickFunction · 0.70
changesMethod · 0.45
onChangeMethod · 0.45

Tested by

no test coverage detected