Add: noNotify option for BaseArrayClass
MODIFY
www/BaseArrayClass.js
www/BaseArrayClass.js
@@ -88,13 +88,13 @@ function BaseArrayClass(array) {
});
};
- self.empty = function() {
+ self.empty = function(noNotify) {
var tmp = [];
for (var i = 0; i < _array.length; i++) {
tmp.push(1);
}
tmp.forEach(function() {
- self.removeAt(0);
+ self.removeAt(0, noNotify);
});
};
@@ -106,14 +106,16 @@ function BaseArrayClass(array) {
return _array.length;
};
- self.insertAt = function(index, value) {
+ self.insertAt = function(index, value, noNotify) {
if (index > _array.length) {
for (var i = _array.length; i <= index; i++) {
_array[i] = undefined;
}
}
_array[index] = value;
+ if (noNotify !== true) {
self.trigger("insert_at", index);
+ }
};
self.getArray = function() {
@@ -124,24 +126,30 @@ function BaseArrayClass(array) {
return _array[index];
};
- self.setAt = function(index, value) {
+ self.setAt = function(index, value, noNotify) {
var prev = _array[index];
_array[index] = value;
+ if (noNotify !== true) {
self.trigger("set_at", index, prev);
+ }
};
- self.removeAt = function(index) {
+ self.removeAt = function(index, noNotify) {
var value = _array[index];
_array.splice(index, 1);
+ if (noNotify !== true) {
self.trigger("remove_at", index, value);
+ }
return value;
};
- self.pop = function() {
+ self.pop = function(noNotify) {
var index = _array.length - 1;
var value = _array.pop();
+ if (noNotify !== true) {
self.trigger("remove_at", index, value);
+ }
return value;
};

Add: noNotify option for BaseArrayClass