How to use the ember-changeset/-private/change 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
) /*: T | ErrLike */ {
      let changes /*: Changes */ = get(this, CHANGES);
      let isValid /*: boolean */ = validation === true
        || isArray(validation)
        && validation.length === 1
        && (validation /*: any */)[0] === true;

      // Shorthand for `this`.
      let c /*: ChangesetDef */ = this;

      // Happy path: remove `key` from error map.
      c._deleteKey(ERRORS, key);

      // Happy path: update change map.
      if (!isEqual(oldValue, value)) {
        setNestedProperty(changes, key, new Change(value));
      } else if (key in changes) {
        c._deleteKey(CHANGES, key);
      }

      // Happy path: notify that `key` was added.
      c.notifyPropertyChange(CHANGES);
      c.notifyPropertyChange(key);

      // Error case.
      if (!isValid) {
        let v /*: ValidationErr */ = (validation /*: any */);
        return c.addError(key, { value, validation: v });
      }

      // Return new value.
      return value;
github poteto / ember-changeset / addon / index.js View on Github external
let newChanges /*: Changes */ = keys(preparedChanges).reduce((newObj, key) => {
        newObj[key] = new Change(preparedChanges[key]);
        return newObj;
      }, {});