How to use the datx-utils.deprecated function in datx-utils

To help you get started, we’ve selected a few datx-utils 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 infinum / datx / packages / datx / src / CompatModel.ts View on Github external
public update(data: PureModel | IDictionary): object {
    deprecated('model.update is deprecated. Use updateModel() instead.');
    const updateData = Object.assign({ }, data);
    Object.keys(updateData).forEach((key) => {
      if (typeof this[key] === 'function') {
        // tslint:disable-next-line:no-dynamic-delete
        delete updateData[key];
      }
    });

    return updateModel(this, updateData);
  }
github infinum / datx / packages / datx / src / CompatModel.ts View on Github external
constructor(initialData: object, collection?: Collection) {
    super(initialData, collection);

    deprecated('CompatModel is just a migration tool. Please move to Model or PureModel as soon as possible.');

    Object.keys(this.static.refs).forEach((prop) => {
      const refs = getModelMetaKey(this, 'refs');
      if (prop in refs) {
        return;
      }
      const ref = this.static.refs[prop];
      const data = mapItems(this[prop] || this.static.defaults[prop], getModelId);
      assignComputed(this, prop);
      if (typeof ref === 'object') {
        // Back reference
        initModelRef(this, prop, {
          model: ref.model,
          property: ref.property,
          type: ReferenceType.TO_ONE_OR_MANY,
        }, data);
github infinum / datx / packages / datx / src / CompatCollection.ts View on Github external
public get static(): typeof CompatCollection {
    deprecated('collection.static is deprecated.');

    return this.constructor as typeof CompatCollection;
  }
github infinum / datx / packages / datx / src / CompatModel.ts View on Github external
public toJS() {
    deprecated('model.toJS() is deprecated. Use modelToJSON() instead.');

    return modelToJSON(this);
  }
github infinum / datx / packages / datx / src / CompatModel.ts View on Github external
private get __collection() {
    deprecated('model.__collection is deprecated. Use getModelCollection() instead.');

    return getModelCollection(this);
  }
}
github infinum / datx / packages / datx / src / CompatModel.ts View on Github external
public assignRef(key: string, value: any, type?: IType) {
    deprecated('model.assignRef is deprecated. Use initModelRef() instead.');
    const refs = getModelMetaKey(this, 'refs');

    if (refs[key]) {
      return this[key] = value;
    }

    let model = type;
    if (!model) {
      if (value instanceof Array || isObservableArray(value)) {
        model = value.reduce((t, m) => t || getModelType(m), null);
      } else if (value instanceof PureModel) {
        model = getModelType(value);
      }
    }

    if (!model) {
github infinum / datx / packages / datx / src / CompatModel.ts View on Github external
public get static() {
    deprecated('model.static is deprecated.');

    return this.constructor as typeof CompatModel;
  }
github infinum / datx / packages / datx / src / CompatCollection.ts View on Github external
public toJS(): IRawCollection {
    deprecated('collection.toJS() is deprecated. Use collection.toJSON() instead');

    return this.toJSON();
  }
}
github infinum / datx / packages / datx / src / CompatModel.ts View on Github external
public get snapshot() {
    deprecated('model.snapshot is deprecated. Use modelToJSON() instead.');

    return modelToJSON(this);
  }
github infinum / datx / packages / datx / src / CompatCollection.ts View on Github external
constructor(data?) {
    super(data);

    deprecated('CompatCollection is just a migration tool. Please move to Collection as soon as possible.');

    this.static.types.forEach((model) => {
      const type = getModelType(model);
      assignComputed(this, type.toString(), () => this.findAll(type));
    });
  }

datx-utils

DatX lib utils for mixins

MIT
Latest version published 4 years ago

Package Health Score

57 / 100
Full package analysis