Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Questions about Ember

Ember does a bunch of useful, powerful, magical things that makes life easy. However, I find myself often a loss to understand how the magic works or how to hook into it. I think I struggle most to understand how & when things are instantiated, how they magically know of each other (e.g. the app knows all it's models & controllers), and how to instantiate things manually and give them access to all the other classes. Here are some examples:

  • If I create an instance of a controller, how do I make sure it has access to the app containers?
  • In Ember-CLI, how does Ember know about all the models/controllers/etc I create? When I write export default PostController, how does Ember register that as a controller and add it to the container?
  • In Ember-CLI, filenames & folder names make a difference. If files are named something unexpected, the documentation writes that they need to be imported automiatcally. Where would such an import statement go? What is the code path that the abnormally named class has to skip because of it's file name? In other words, what magic is it missing out on? (e.g. import FooModel from "./models/foo-model";)
  • Why is there a separate lookup mechanism for the store? Why not one lookup method (lookup/lookupFactory) What do we gain other than less words to type?
  • When Ember.Application.create is called, what happens? What does Ember do before App.create() and what does it do after? If you want code to run before the app fires, where do you put it? Do all the models/controller/etc have to be loaded before App.create is called?
  • If you reference a view or controller in a template (e.g {{view PostView content="post" controller="post"}}), does the current container get injected into it every time? Corrolary -- is there a way to instantiate a view/controller where the view/controller would not have the container added to it?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.