Example #1
0
 this.update = function update(name, property, value) {
     var item;
     if (this.has(name)) {
         item = this.get(name);
         nestedProperty.set(item, property, value);
         _storeObservable.notify("updated", property, value);
         _valueObservable.notify(name, item, "updated");
         return true;
     } else {
         return false;
     }
 };
Example #2
0
 this.del = function del(name) {
     var previous;
     if (this.has(name)) {
         if (!this.alter("splice", name, 1)) {
             previous = _data[name];
             delete _data[name];
             _storeObservable.notify("deleted", name, undefined, previous);
             _valueObservable.notify(name, _data[name], "deleted", previous);
         }
         return true;
     } else {
         return false;
     }
 };
Example #3
0
    this.set = function set(name, value) {
        var hasPrevious,
            previousValue,
            action;

        if (typeof name != "undefined") {
            hasPrevious = this.has(name);
            previousValue = this.get(name);
            _data[name] = value;
            action = hasPrevious ? "updated" : "added";
            _storeObservable.notify(action, name, _data[name], previousValue);
            _valueObservable.notify(name, _data[name], action, previousValue);
            return true;
        } else {
            return false;
        }
    };
Example #4
0
    this.reset = function reset(data) {
        if (typeof data == "object") {
            var previousData = clone(_data);
            _data = clone(data) || {};
            _notifyDiffs(previousData);
            _storeObservable.notify("resetted", _data, previousData);
            return true;
        } else {
            return false;
        }

    };
Example #5
0
    this.alter = function alter(func) {
        var apply,
            previousData;

        if (_data[func]) {
            previousData = clone(_data);
            apply = this.proxy.apply(this, arguments);
            _notifyDiffs(previousData);
            _storeObservable.notify("altered", _data, previousData);
            return apply;
        } else {
            return false;
        }
    };
Example #6
0
 diffs[value].forEach(function (dataIndex) {
        _storeObservable.notify(value, dataIndex, _data[dataIndex]);
        _valueObservable.notify(dataIndex, _data[dataIndex], value);
 });