Hi everyone!
So, I’ve hit what I think is a weird issue and I wanted to ask a couple questions around it.
Basically, I have a parent-child relationship with a hasMany that’s “async: true”. I ran into an edge case where sometimes a user can delete the model while it’s in the process of loading up the hasMany. In that case, should the promise be automatically cancelled?
The code looks something like (I’m using ember-cli and I’ve omitted the ES6 import/export statements)
# models/my-parent.coffee
MyParent = DS.Model.extend
name: DS.attr('string')
myChildren: DS.hasMany('my-child', async: true)
doStuff: (->
@get('myChildren').then (children) =>
# there's a race condition where sometimes this callback
# is triggered after the parent model has been deleted!
return if @get('isDeleted')
# ... do stuff on children ...
).observes('name')
I’m more than happy to work on a patch if that’s something that would be useful!
Cheers,
Nik