Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember App Kit: Set Resolver outside of Ember.Application.create()

To keep it short:

Is it possible to set up the Resolver of the application outside of the Ember.Application.create() block?

Ideally, I would like to set the Resolver in a Ember.Application.initializer#initialize() function. Something like:

import CustomResolver from 'appkit/utils/resolver/custom';
import CustomAjax from 'appkit/utils/ajax/custom';

Ember.Application.initializer({
  name: 'resolver_setup',

  initialize: function (container, application) {
     // NOTE: For an unknown reason (unknown to me!) I can't import CustomAjax in CustomResolver...
     application.set('Resolver', CustomResolver.create({ajax: CustomAjax.create({})});
  }
});

Is this possible?

P.S.: The reason why I need a custom resolver is, that I'm fetching all templates from the server instead of delivering them to the user on application start. Therefore I'm extending the ember-jj-abrams-resolver which is used by default within EAK...

like image 427
herom Avatar asked Nov 11 '22 10:11

herom


1 Answers

I don't think initializers can help you to set a custom Resolver, according to the source code, container is been set earlier than any initializers, resolver is a property of container.

You set the Resolver property inside initializer, but this will not be used by the process of set up the container. I think the right way is to reopen the Ember.Application and set the Resolver before create the Ember.Application.

Ember.Application.reopenClass({
  Resolver: YOUR_CUSTOM_RESOLVER_NAME
});

Ember.Application.create({...});
like image 122
nightire Avatar answered Jan 04 '23 02:01

nightire