How to use the @ember-data/store/-private.diffArray function in @ember-data/store

To help you get started, we’ve selected a few @ember-data/store examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github emberjs / data / packages / model / addon / -private / system / many-array.js View on Github external
flushCanonical(toSet, isInitialized = true) {
    // It’s possible the parent side of the relationship may have been unloaded by this point
    if (!_objectIsAlive(this)) {
      return;
    }
    // diff to find changes
    let diff = diffArray(this.currentState, toSet);
    if (diff.firstChangeIndex !== null) {
      // it's null if no change found
      // we found a change
      this.arrayContentWillChange(diff.firstChangeIndex, diff.removedCount, diff.addedCount);
      this.set('length', toSet.length);
      this.currentState = toSet.slice();
      this.arrayContentDidChange(diff.firstChangeIndex, diff.removedCount, diff.addedCount);
      if (isInitialized && diff.addedCount > 0) {
        //notify only on additions
        //TODO only notify if unloaded
        this.internalModel.manyArrayRecordAdded(this.get('key'));
      }
    }
  },