コード例 #1
0
ファイル: data_adapter.js プロジェクト: jrjohnson/ember.js
 let release = () => removeArrayObserver(records, this, observer);
コード例 #2
0
ファイル: data_adapter.js プロジェクト: jrjohnson/ember.js
 release = () => {
   releaseMethods.forEach(fn => fn());
   removeArrayObserver(records, this, observer);
   this.releaseMethods.removeObject(release);
 };
コード例 #3
0
ファイル: array_proxy.js プロジェクト: GowthamMK/ember.js
  _addArrangedContentArrayObsever() {
    let arrangedContent = get(this, 'arrangedContent');
    if (arrangedContent) {
      assert('Can\'t set ArrayProxy\'s content to itself', arrangedContent !== this);
      assert(`ArrayProxy expects an Array or ArrayProxy, but you passed ${typeof arrangedContent}`,
        isArray(arrangedContent) || arrangedContent.isDestroyed);

      addArrayObserver(arrangedContent, this, ARRAY_OBSERVER_MAPPING);

      this._arrangedContent = arrangedContent;
    }
  },

  _removeArrangedContentArrayObsever() {
    if (this._arrangedContent) {
      removeArrayObserver(this._arrangedContent, this, ARRAY_OBSERVER_MAPPING);
    }
  },

  _arrangedContentArrayWillChange() {},

  _arrangedContentArrayDidChange(proxy, idx, removedCnt, addedCnt) {
    this.arrayContentWillChange(idx, removedCnt, addedCnt);

    let dirtyIndex = idx;
    if (dirtyIndex < 0) {
      let length = get(this._arrangedContent, 'length');
      dirtyIndex += length + removedCnt - addedCnt;
    }

    if (this._objectsDirtyIndex === -1) {
コード例 #4
0
ファイル: array.js プロジェクト: jrjohnson/ember.js
  },

  /**
    Removes an array observer from the object if the observer is current
    registered. Calling this method multiple times with the same object will
    have no effect.

    @method removeArrayObserver
    @param {Object} target The object observing the array.
    @param {Object} opts Optional hash of configuration options including
      `willChange` and `didChange` option.
    @return {EmberArray} receiver
    @public
  */
  removeArrayObserver(target, opts) {
    return removeArrayObserver(this, target, opts);
  },

  /**
    Becomes true whenever the array currently has observers watching changes
    on the array.

    @property {Boolean} hasArrayObservers
    @public
  */
  hasArrayObservers: computed(function() {
    return hasListeners(this, '@array:change') || hasListeners(this, '@array:before');
  }),

  /**
    If you are implementing an object that supports `EmberArray`, call this
コード例 #5
0
ファイル: array.js プロジェクト: xiujunma/ember.js
      while (--loc >= 0) {
        obj.addObserver(keys[loc], this, 'propertyDidChange');
      }
    } else {
      this.isEnabled = false;
    }
    return this;
  },

  observeArray(obj) {
    addArrayObserver(obj, this);
    return this;
  },

  stopObserveArray(obj) {
    removeArrayObserver(obj, this);
    return this;
  },

  propertyDidChange(target, key, value) {
    if (this._keys[key] === undefined) {
      this._keys[key] = 0;
    }
    this._keys[key]++;
    this._values[key] = value;
  },

  arrayWillChange() {
    this.assert.equal(this._before, null, 'should only call once');
    this._before = Array.prototype.slice.call(arguments);
  },