Skip to content

Commit

Permalink
Add option to disable row reactivity. (#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
aslagle committed Aug 1, 2016
1 parent 7abf04d commit 458d9bf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
36 changes: 19 additions & 17 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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();
});
});
Expand Down
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
@@ -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"
});
Expand Down

0 comments on commit 458d9bf

Please sign in to comment.