I have an ES6 class in Ember 3.1 which is being handed an ember data object called certifciate
. I would like to be able to call .reload()
on that certificate as follows:
@action
showCertificateInfo(this: DomainCard, certificate) {
this.setProperties({
isShowingCertificateModal: true,
selectedCert: certificate,
})
certificate
.reload()
.then(() => {
this.set('isShowingCertificateModal', true)
})
.catch(e => {
// TODO: handle this
})
}
However, if I do this, then Ember gives the following error/warning:
Assertion Failed: You attempted to access the 'reload' property
(of <DS.PRomiseObject:ember796>)... However in this case4 the object
in quetstion is a special kind of Ember object (a proxy). Therefore,
it is still necessary to use` .get(‘reload’)` in this case.
If I do as the code suggests and call .get('reload')
instead, then I get an internal Ember error that this
is not defined when calling this._internalModel
. I get the same error when doing:
const reload = certificate.get('reload').bind(certificate)
reload().then()
...
What do I need to do to be able to reload this ember data object properly?
Actually, whe fundamental problem seems to be that the certificate model had an async relationship to the domain model, and by using {async: false}
, we remove the need to get a proxyPromise object returned to us and remove the need to pull the content
object out of the promise.