I'm trying to setup a PromiseProxy Service that returns an Ember Data model, but the result doesn't seem to set the content
property.
My service looks like this:
import Ember from 'ember';
const { computed, inject, ObjectProxy, PromiseProxyMixin } = Ember;
export default ObjectProxy.extend(PromiseProxyMixin, {
isServiceFactory: true,
store: inject.service(),
promise: computed({
get() {
var store = this.get('store');
return store.findRecord('community', window.community.id);
}
})
});
I then inject this service into the following locations:
export function initialize(container, application) {
application.inject('controller', 'community', 'service:community');
application.inject('route', 'community', 'service:community');
application.inject('model', 'community', 'service:community');
application.inject('component', 'community', 'service:community');
}
export default {
name: 'community',
after: 'store',
initialize: initialize
};
And then I use it as a model in my application route as a sort of deferReadiness
workaround, since my whole app depends on this one model which is used throughout and expected to be there.
export default Ember.Route.extend({
model() {
return this.get('community');
}
});
The issue is that it goes on to other routes, and properties on the community
object are not there, i.e. content
isn't set. Also community.isPending
is true
. The CP does get hit and the data comes back (I tested with a then
in the CP).
Here is a full gist example: http://ift.tt/1Yyq963
Aucun commentaire:
Enregistrer un commentaire