How to use the ember-changeset/utils/merge-nested function in ember-changeset

To help you get started, we’ve selected a few ember-changeset 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 poteto / ember-changeset / addon / index.js View on Github external
assert('Cannot merge with a non-changeset', isChangeset(changeset));
      assert('Cannot merge with a changeset of different content', get(changeset, CONTENT) === content);

      if (get(this, 'isPristine') && get(changeset, 'isPristine')) {
        return this;
      }

      let c1 /*: Changes    */ = get(this, CHANGES);
      let c2 /*: Changes    */ = get(changeset, CHANGES);
      let e1 /*: Errors     */ = get(this, ERRORS);
      let e2 /*: Errors     */ = get(changeset, ERRORS);

      let newChangeset  /*: ChangesetDef */ = new Changeset(content, get(this, VALIDATOR));
      let newErrors     /*: Errors  */      = objectWithout(keys(c2), e1);
      let newChanges    /*: Changes */      = objectWithout(keys(e2), c1);
      let mergedErrors  /*: Errors  */      = mergeNested(newErrors, e2);
      let mergedChanges /*: Changes */      = mergeNested(newChanges, c2);

      newChangeset[ERRORS]  = mergedErrors;
      newChangeset[CHANGES] = mergedChanges;
      newChangeset._notifyVirtualProperties();
      return newChangeset;
    },
github poteto / ember-changeset / addon / index.js View on Github external
assert('Cannot merge with a changeset of different content', get(changeset, CONTENT) === content);

      if (get(this, 'isPristine') && get(changeset, 'isPristine')) {
        return this;
      }

      let c1 /*: Changes    */ = get(this, CHANGES);
      let c2 /*: Changes    */ = get(changeset, CHANGES);
      let e1 /*: Errors     */ = get(this, ERRORS);
      let e2 /*: Errors     */ = get(changeset, ERRORS);

      let newChangeset  /*: ChangesetDef */ = new Changeset(content, get(this, VALIDATOR));
      let newErrors     /*: Errors  */      = objectWithout(keys(c2), e1);
      let newChanges    /*: Changes */      = objectWithout(keys(e2), c1);
      let mergedErrors  /*: Errors  */      = mergeNested(newErrors, e2);
      let mergedChanges /*: Changes */      = mergeNested(newChanges, c2);

      newChangeset[ERRORS]  = mergedErrors;
      newChangeset[CHANGES] = mergedChanges;
      newChangeset._notifyVirtualProperties();
      return newChangeset;
    },