Skip to content

Instantly share code, notes, and snippets.

@elidupuis
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elidupuis/be03c8f209334a18b604 to your computer and use it in GitHub Desktop.
Save elidupuis/be03c8f209334a18b604 to your computer and use it in GitHub Desktop.
Ember inject POJO
// app/initializers/foo.js
var POJO = {
bar: 'this is your POJO'
// whatever you need here
// this can also be import from another file...
};
export function initialize(container, application) {
application.register('pojo:main', POJO, { instantiate: false, singleton: true });
application.inject('route', 'foo', 'pojo:main');
// application.inject('component', 'foo', 'pojo:main');
// inject whereever you need it...
// then in your routes (or whereever) do:
// `this.foo` and you should have your POJO
}
export default {
name: 'foo',
initialize: initialize
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment