How to use the @ember-data/store/-debug.assertPolymorphicType 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 / record-data / addon / -private / relationships / state / belongs-to.ts View on Github external
addRecordData(recordData: RelationshipRecordData) {
    if (this.members.has(recordData)) {
      return;
    }

    // TODO Igor cleanup
    assertPolymorphicType(this.recordData, this.relationshipMeta, recordData, this.store);

    if (this.inverseRecordData) {
      this.removeRecordData(this.inverseRecordData);
    }

    this.inverseRecordData = recordData;
    super.addRecordData(recordData);
    this.notifyBelongsToChange();
  }
github emberjs / data / packages / record-data / addon / -private / relationships / state / has-many.ts View on Github external
addRecordData(recordData: RelationshipRecordData, idx?: number) {
    if (this.members.has(recordData)) {
      return;
    }

    // TODO Type this
    assertPolymorphicType(this.recordData, this.relationshipMeta, recordData, this.store);
    super.addRecordData(recordData, idx);
    // make lazy later
    if (idx === undefined) {
      idx = this.currentState.length;
    }
    this.currentState.splice(idx, 0, recordData);
    // TODO Igor consider making direct to remove the indirection
    // We are not lazily accessing the manyArray here because the change is coming from app side
    // this.manyArray.flushCanonical(this.currentState);
    this.notifyHasManyChange();
  }
github emberjs / data / packages / store / addon / -private / system / references / belongs-to.js View on Github external
return resolve(objectOrPromise).then(data => {
      let record;

      if (DEPRECATE_BELONGS_TO_REFERENCE_PUSH && peekRecordIdentifier(data)) {
        deprecate('Pushing a record into a BelongsToReference is deprecated', false, {
          id: 'ember-data:belongs-to-reference-push-record',
          until: '4.0',
        });
        record = data;
      } else {
        record = this.store.push(data);
      }

      assertPolymorphicType(
        this.internalModel,
        this.belongsToRelationship.relationshipMeta,
        record._internalModel,
        this.store
      );

      //TODO Igor cleanup, maybe move to relationship push
      this.belongsToRelationship.setCanonicalRecordData(recordDataFor(record));

      return record;
    });
  }
github emberjs / data / packages / store / addon / -private / system / references / has-many.js View on Github external
let internalModels = array.map(obj => {
        let record = this.store.push(obj);

        if (DEBUG) {
          let relationshipMeta = this.hasManyRelationship.relationshipMeta;
          assertPolymorphicType(this.internalModel, relationshipMeta, record._internalModel, this.store);
        }
        return recordDataFor(record);
      });