私の答え - すでに読み込まれたレコードを格納するために、独自のメモリ内ストア(サービスはEmber-wayソリューションのように見えます)を作成します。例えば、それは、このような構造を有することができ:
// app/services/store.js
export default Ember.Service.extend({
ajax: Ember.inject.service(),
store: {
applications: [],
tests: []
},
getTest(id) {
const store = this.get('store');
return new Ember.RSVP.Promise(resolve => {
const loadedTest = store.tests.findBy('id', id);
if (loadedTest) {
return resolve(loadedTest);
}
this.get('ajax').getRequest(urlForGettingTestWithConcreteId).then(test => {
if (test.application) {
const application = store.applications.findBy('id', test.application);
if (application) {
test.application = application;
store.tests.pushObject(test);
return resolve(test);
}
this.get('ajax').getRequest(test.application).then(application => {
test.application = application;
store.applications.pushObject(application);
store.tests.pushObject(test);
resolve(test);
});
}
});
});
}
});
それは混合擬似コードとコードを動作するはずですが、あなたは簡単にそれはあなたのアプリケーションで作業を取得する必要があります。 :)