Class GlobalsResolver
public
Extends:
EmberObject
Module:
@ember/application
import GlobalsResolver from '@ember/application/globals-resolver';
The DefaultResolver defines the default lookup rules to resolve container lookups before consulting the container for registered items:
- templates are looked up on
Ember.TEMPLATES
- other names are looked up on the application after converting
the name. For example,
controller:post
looks upApp.PostController
by default. - there are some nuances (see examples below)
How Resolving Works
The container calls this object's resolve
method with the
fullName
argument.
It first parses the fullName into an object using parseName
.
Then it checks for the presence of a type-specific instance
method of the form resolve[Type]
and calls it if it exists.
For example if it was resolving 'template:post', it would call
the resolveTemplate
method.
Its last resort is to call the resolveOther
method.
The methods of this object are designed to be easy to override in a subclass. For example, you could enhance how a template is resolved like so:
app/app.js
import Application from '@ember/application';
import GlobalsResolver from '@ember/application/globals-resolver';
App = Application.create({
Resolver: GlobalsResolver.extend({
resolveTemplate(parsedName) {
let resolvedTemplate = this._super(parsedName);
if (resolvedTemplate) { return resolvedTemplate; }
return Ember.TEMPLATES['not_found'];
}
})
});
Some examples of how names are resolved:
'template:post' //=> Ember.TEMPLATES['post']
'template:posts/byline' //=> Ember.TEMPLATES['posts/byline']
'template:posts.byline' //=> Ember.TEMPLATES['posts/byline']
'template:blogPost' //=> Ember.TEMPLATES['blog-post']
'controller:post' //=> App.PostController
'controller:posts.index' //=> App.PostsIndexController
'controller:blog/post' //=> Blog.PostController
'controller:basic' //=> Controller
'route:post' //=> App.PostRoute
'route:posts.index' //=> App.PostsIndexRoute
'route:blog/post' //=> Blog.PostRoute
'route:basic' //=> Route
'foo:post' //=> App.PostFoo
'model:post' //=> App.Post
Methods
- addObserver
- cacheFor
- decrementProperty
- destroy
- get
- getProperties
- getWithDefault
- incrementProperty
- init
- notifyPropertyChange
- removeObserver
- resolve
- set
- setProperties
- toString
- toggleProperty
- willDestroy
Properties
Events
No documented items