I'm having trouble unloading data models and having them properly re-populate when API calls are made.
The models:
/* Model Foo */
export default DS.Model.extend({
bars: DS.hasMany('bar', { async: true })
});
/* Model Bar */
export default DS.Model.extend({
foo: DS.belongsTo('foo', { async: true, inverse: 'bars' })
});
At a point in the app, both foo and bar are unloaded from ember data store and then reloaded from an API call. Like so:
/* Unload and reload snippet */
this.store.unloadAll('bar');
this.store.unloadAll('foo');
let bars = this.store.filter('bar', {
queryParam: x
}, function(bar) {
return x === bar.x
});
let foos = this.store.filter('foo', {
queryParam: y
}, function(foo) {
return y === bar.y
});
let self = this;
Ember.RSVP.all([foos, bars]).finally(function() {
self.controller.set('model.foos', foos);
self.controller.set('model.bars', bars);
});
The problem arises in a computed property that is dependent on these model changes.
/* Computed property elsewhere in app */
compProp: Ember.computed('foo.bars.[]', function() {
let tmp = this.get('foo.bars'); /* <-- Error generating line */
.
.
.
})
This line gives me the following error: Assertion Failed: calling set on destroyed object: <DS.PromiseManyArray:ember1995>.content = <DS.ManyArray:ember3320>
Thanks for any help!
Side notes:
- I'm aware
store.filter()
is deprecated. I'm upgrading the app from an earlier Ember version and using ember-data-filter addon for temporary compatibility. - This was working on Ember 1.13.
Aucun commentaire:
Enregistrer un commentaire