Skip to content

Commit 844b6cd

Browse files
committed
Configurable rate limit dirty check for performance reasons #201
1 parent 4b31b7f commit 844b6cd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

grails-app/assets/javascripts/knockout-utils.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
* @param isInitiallyDirty
8383
* @returns an object (function) with the methods 'isDirty' and 'reset'
8484
*/
85-
ko.dirtyFlag = function (root, isInitiallyDirty) {
85+
ko.dirtyFlag = function (root, isInitiallyDirty, rateLimit) {
8686
var result = function () {
8787
};
8888
var _isInitiallyDirty = ko.observable(isInitiallyDirty || false);
@@ -93,11 +93,12 @@
9393
var _initialState = ko.observable(getRepresentation());
9494

9595
result.isDirty = ko.pureComputed(function () {
96-
console.log("isDirty called");
9796
var dirty = _isInitiallyDirty() || _initialState() !== getRepresentation();
98-
9997
return dirty;
100-
}).extend({rateLimit: 500});
98+
});
99+
if (rateLimit) {
100+
result.isDirty = result.isDirty.extend({rateLimit: 500});
101+
}
101102

102103
result.reset = function () {
103104
_initialState(getRepresentation());

0 commit comments

Comments
 (0)