As the following, user has serviceinfo, which is of userService type:
User = DS.Model.extend({
serviceinfo: belongsTo('userService', {async: true})
});
UserService = DS.Model.extend({
online: attr('number', {defaultValue: 0})
});
When the app start, online of user with id '1' is set to 1:
self.get('store').find('user', '1').then(function(user){
user.get('serviceinfo').then(function(serviceinfo){
serviceinfo.set('online', 1);
});
});
and after a while, pushPayload is called when a message with userService data(id is '1', online is 2 ) is received:
self.get('store').pushPayload('userService', {userService: msg});
but the state gotten after that by:
self.get('store').getById('user', '1').get('serviceinfo.online');
is still '1', that is to say, pushPayload can not change online property in userService model if 'set' is called firstly.
What is the problem?
Aucun commentaire:
Enregistrer un commentaire