The properties 'isLoading', 'isLoaded' and 'isSaving' are implemented as computed properties. In Ember, computed properties are lazy and do not calculate their state until they are requested for the first time using .get or displayed in a template. Therefore, although conceptually we, as developers, can know that the isLoading value changes and returns a different value when calling record.get('isLoading') , because the Ember value has the isLoading value equal to undefined, while some code explicitly requests Ember for this value, and Ember takes time to calculate its state.
As a result, when you use Ember.observer to view the computed property, it will not be able to detect changes in the computed property until any other code tries to access the value of the computed property.
Observers also have several other messages that you might want to know about. @stefanpenner talks well about its problems https://www.youtube.com/watch?v=vvZEddrClAQ and why they should be used sparingly.
In order for your mixin to fire observer events, you will need to access these properties anywhere. The best place for this seems to be in your onInit function. If you add this.getProperties('isReloading', 'isSaving', 'isLoading', 'isLoaded'); into the onInit function, then Ember will calculate these values, and observers will run correctly when the values ββof these properties are changed.
DS.Model Life Cycle
Under the hood, Ember Data stores a state machine for recording recordings. This state machine is used to track record relationships with the server. At a high level, these are states in which an Ember Data record can be written:
- empty
- loading
- loading
- deleted
empty Is the state in which each entry begins its life. Another thing is that this empty fact is not very important.
loading Is the state a record when Ember Data requests data from the server for the first time.
loaded Is the state a record when Ember Data receives some information from the server about the record. It has several subnets that are used to track changes made to the local record that were not saved on the server. If the record is created on the client side, it will be placed directly in the loaded.created.uncommitted state.
deleted is the transfer for deleted records. The deleted.saved deleted.saved means that the server has confirmed the deletion of this record. The deleted.uncommitted deleted.uncommitted means that the record was deleted locally, but record.save() not called.
The current state of the record is displayed by the currentState property in the record. isLoading , isLoaded and isSaving are all aliases for currentState.isLoading , currentState.isLoaded , currentState.isSaving , since each state in the destination machine has predefined values ββfor all of these properties.
I hope this DS.Model machine state explanation helps.
As an additional thing to check, are the lifecycle event bindings that appear in DS.Model instances. http://emberjs.com/api/data/classes/DS.Model.html#event_becameError