So the model for this app for all routes is set up like this:
model(params) {
let config = this.get('store').findRecord(params.config_type, params.config_id);
let c = Ember.RSVP.hash({config});
console.log('aa');
console.log(c);
let devices = this.get('store').findAllOfType('device', ENV.CFG_TYPE[params.config_type]);
let licenses = this.get('store').findAll('license');
return Ember.RSVP.hash({
configType: params.config_type,
config: config,
devices: devices,
licenses: licenses
});
},
I need to change the devices query to use a secondary criteria which is held inside the config which is returned by the first query. The only problem is this isn't resolved and doesn't have the data in it.
When I log out c I see initially undefined for the _results property, then when I expand it, it shows the config object.
I realize this is because the promise isn't resolved yet, and is resolved some time in the future, but I need that data to get the right devices. I don't want to pass them as query params as these are two separate pieces of data I need.
I was thinking I could do .then() on the config line and return the Ember.RSVP.hash in there but that would return it to model() and I am not sure how I would return it from there, or if it would even return from there, or if config would now be equal to the RSVP hash and not the config promise/object.
My options are:
-
Find a way to pass it somehow from one route, which has the same config object already in the model, to this one, without using query params
-
Setup the entire model in the callback from the first query somehow (the findRecord() one)
Totally clueless on how to do it either way.
Aucun commentaire:
Enregistrer un commentaire