How do I write initializers for registering and injecting in Ember.JS?

I first came across the idea of using initializers from this question regarding the use of local storage in ember:

How to use HTML5 Local Storage with Ember.js?

Subsequent research has revealed that initializers are poorly documented at the moment and because of which there a few things that aren't perfectly clear.

In the question listed above, the accepted answer suggests creating two initializers, one to register and one to inject. In other examples I've seen both the register and injection done in the same initializer. I'm developing using the Ember App Kit which uses ES6 modules and having two separate files, one for the injection initializer and one for the register initializer seems a bit cumbersome. The following seems to work fine, but the question becomes, am I supposed to use two initializers for some reason?


Register and Inject LocalSessionStorage

//import local session storage model
import LocalSessionStorage from 'appkit/models/local_session_storage';

//use local session storage to act as a session manager
export default {
  name: "registerStorage",
  initialize: function(container, application) {
    application.register('storage:session', LocalSessionStorage, {singleton: true});
    application.inject('controller', 'session', 'storage:session');
    application.inject('route', 'session', 'storage:session');


//Use an initializer to inject local session storage
//to all routes & controllers
import SessionInitializer from 'appkit/initializers/local_session';

Additionally, the examples use a specific format for the name of the class being registered and injected, such as storage:main. The API references the variable as the fullName, but doesn't really say what a valid name should be. Here's are the examples from the register function in the API documentation:

App = Ember.Application.create();

App.Person  = Ember.Object.extend({});
App.Orange  = Ember.Object.extend({});
App.Email   = Ember.Object.extend({});
App.session = Ember.Object.create({});

App.register('model:user', App.Person, {singleton: false });
App.register('fruit:favorite', App.Orange);
App.register('communication:main', App.Email, {singleton: false});
App.register('session', App.session, {instantiate: false});

However when I tried to name my initializer just session as is demonstrated in the last example, I get this error from Ember:

Uncaught TypeError: Invalid Fullname, expected: `type:name` got: session 

The error originates from this function in ember.js:

var VALID_FULL_NAME_REGEXP = /^[^:]+.+:[^:]+$/;
function validateFullName(fullName) {
  if (!VALID_FULL_NAME_REGEXP.test(fullName)) {
    throw new TypeError('Invalid Fullname, expected: `type:name` got: ' + fullName);


The error just means, that Ember expects you to specify a name for the new type. For example 'session:main' instead of just 'session'.

App.register('session:main', App.session, {instantiate: false});

Need Your Help

C++ pointer to objects

c++ object pointers

In C++ do you always have initialize a pointer to an object with the new keyword?

Conditional Binary Unpacking With Node.js

node.js binary conditional unpack

I have been tasked to create a node.js program which has three main components: listen for incoming data (which comes in as packed binary), unpack and parse that data, then post it to the postgreSQL