Quantcast
Viewing all articles
Browse latest Browse all 4826

An attribute that can accept both API response and computed

@Jeffrey_Cheung wrote:

Hello, I am using the following version of Ember:

DEBUG: -------------------------------
DEBUG: Ember      : 2.8.2
DEBUG: Ember Data : 2.8.1
DEBUG: jQuery     : 2.1.4
DEBUG: -------------------------------

I want a field behave like this: if my server response has field's value, use it, else compute it using comput property.
For example something like this:

// human.js
import DS from 'ember-data';
export default DS.Model.extend({
  money: DS.attr('number'),
  rich: DS.attr('boolean'),
  rich: Ember.computed.gt('money', 1000000)
});

Then this human is rich either determine by API or computed by money he has.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4826

Trending Articles