fermata-couchdb
Advanced tools
Comparing version 0.10.9 to 0.11.0
@@ -52,2 +52,6 @@ /* CouchDB (and friends) plugin for Fermata, with support for change events and default base URL. | ||
plugin.warn = function () { | ||
if (console && console.warn) console.warn.apply(console, arguments); | ||
}; | ||
plugin.watchChanges = function (db, lastSeq, callback, interval) { | ||
@@ -64,5 +68,2 @@ var currentSeq = lastSeq, | ||
} | ||
function warn() { | ||
if (console && console.warn) console.warn.apply(console, arguments); | ||
} | ||
@@ -73,3 +74,3 @@ function safeCallback() { | ||
} catch (e) { | ||
warn("CouchDB _changes callback handler threw exception", e); | ||
plugin.warn("CouchDB _changes callback handler threw exception", e); | ||
} | ||
@@ -91,3 +92,3 @@ } | ||
var _d = (responseType === 'stream') ? '<stream>' : d; | ||
warn("Couldn't fetch CouchDB _changes feed, trying again in "+backoff+" milliseconds.", e, _d); | ||
plugin.warn("Couldn't fetch CouchDB _changes feed, trying again in "+backoff+" milliseconds.", e, _d); | ||
safeCallback([], e); | ||
@@ -111,3 +112,3 @@ setTimeout(poll, backoff); | ||
} catch (e) { | ||
warn("CouchDB _changes watcher failed to parse part of response", e); | ||
plugin.warn("CouchDB _changes watcher failed to parse part of response", e); | ||
} | ||
@@ -114,0 +115,0 @@ prev = lines[last]; |
{ | ||
"name": "fermata-couchdb", | ||
"version": "0.10.9", | ||
"version": "0.11.0", | ||
"description": "CouchDB helpers for Fermata", | ||
@@ -5,0 +5,0 @@ "main": "fermata-couchdb.js", |
@@ -55,2 +55,3 @@ # fermata-couchdb | ||
- `fermata.plugins.couchdb.watchChanges(databaseUrl, lastSeq, callback[, interval])` — Starts monitoring changes, returning a watcher object whose API is documented below, along with this method's parameters. This helper encapsulates best-practice polling behaviors depending on the monitoring mode (determined via `interval`). For the continuous and long-polling cases (see below), this includes exponential backoff on error. | ||
- `fermata.plugins.couchdb.warn ≈ console.warn.bind(console);` — The changes watcher may emit some warnings to the console when it is available. You can override this method if you wish to handle these in some custom way. Your function should accept multiple arguments of any type, as `console.warn` does, but doesn't need to support any [string substition](https://developer.mozilla.org/en-US/docs/Web/API/console#Using_string_substitutions) (format specifiers). | ||
@@ -70,2 +71,3 @@ | ||
- `watcher.cancel()` — Stops (or pauses) monitoring changes. Any pending request will be aborted and no more callbacks will be sent; however, if you keep a reference to the watcher, its current status is preserved. | ||
- `watcher.pause()` — Alias for `.cancel()`. | ||
- `watcher.restart()` — Resumes monitoring of changes. Use this to "unpause" a cancelled watcher. | ||
@@ -72,0 +74,0 @@ - `watcher.getStatus()` — Returns an object with information about the monitoring status. Currently the only proprerty provided is `update_seq`, which is the last processed sequence. |
15962
114