Skip to content

Instantly share code, notes, and snippets.

Last active June 22, 2020 20:03
What would you like to do?
Adds some runtime globals for making Ember.js developing a breeze
export function initialize(application) {
let { environment } = application.resolveRegistration('config:environment');
if (environment !== "production") {
This basically exposes the application, pretty useful because
you can use stuff like this from the console.
window.App = application;
This will gives us access to the store easily, to make fast queries or checks!
Fast and easy:
var s ='some-model', 1);'some-model', {name: 'Alberto'})
*/ = application.__container__.lookup("service:store");
//shortcuts for every emberjs base type lookup
let objects = [
objects.forEach(type => {
window.App[type] = function(name) {
return application.lookup(`${type}:${name}`)
Use a class for ergonimics with getters, grab the current model, route or controller based
on the current active route!
class CurrentContext {
get model() {
return application.lookup(
get controller() {
return application.lookup(
get route() {
return application.lookup(
window.App.ctx = new CurrentContext();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment