diff --git a/README.md b/README.md index 671bb02..f3f809f 100644 --- a/README.md +++ b/README.md @@ -428,6 +428,8 @@ The following options are available in the settings argument to ReactiveTable.pu Whether to use filter text as a regular expression instead of a regular search term. When true, users will be able to enter regular expressions to filter the table, but your application may be vulnerable to a [ReDoS](http://en.wikipedia.org/wiki/ReDoS) attack. Also, when true, users won't be able to use special characters in filter text without escaping them. - disablePageCountReactivity (Boolean - *default=* **false**): Whether to disable reactive updates of the displayed page count. Setting this to true will improve performance and is a good idea if you don't need the page count to automatically update. +- disableRowReactivity (Boolean - *default=* **false**): + Whether to disable reactive updates of the displayed rows (which rows are displayed and their contents). Setting both this and disablePageCountReactivity to true will disable all reactivity. Regex Examples: A user filters with "me + you" diff --git a/lib/server.js b/lib/server.js index a555bc6..eec325d 100644 --- a/lib/server.js +++ b/lib/server.js @@ -72,26 +72,28 @@ ReactiveTable.publish = function (name, collectionOrFunction, selectorOrFunction self.added("reactive-table-rows-" + publicationId, row._id, row); }); - var initializing = true; + if (!(settings || {}).disableRowReactivity) { + var initializing = true; - var handle = pageCursor.observeChanges({ - added: function (id, fields) { - if (!initializing) { - updateRows(); - } - }, + var handle = pageCursor.observeChanges({ + added: function (id, fields) { + if (!initializing) { + updateRows(); + } + }, - removed: function (id, fields) { - self.removed("reactive-table-rows-" + publicationId, id); - delete rows[id]; - updateRows(); - }, + removed: function (id, fields) { + self.removed("reactive-table-rows-" + publicationId, id); + delete rows[id]; + updateRows(); + }, - changed: function (id, fields) { - updateRows(); - } + changed: function (id, fields) { + updateRows(); + } - }); + }); + } if (!(settings || {}).disablePageCountReactivity) { var countHandle = fullCursor.observeChanges({ @@ -111,7 +113,7 @@ ReactiveTable.publish = function (name, collectionOrFunction, selectorOrFunction self.ready(); self.onStop(function () { - handle.stop(); + if (handle) handle.stop(); if (countHandle) countHandle.stop(); }); }); diff --git a/package.js b/package.js index ca86b2b..d28265d 100644 --- a/package.js +++ b/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: "A reactive table designed for Meteor", - version: "0.8.33", + version: "0.8.34", name: "aslagle:reactive-table", git: "https://github.com/aslagle/reactive-table.git" });