Skip to content

Instantly share code, notes, and snippets.

@rystraum
Last active December 17, 2015 06:59
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 rystraum/5569858 to your computer and use it in GitHub Desktop.
Save rystraum/5569858 to your computer and use it in GitHub Desktop.
Full disclosure: This is my understanding on how Ember works. Feel free to correct me on points where I'm wrong.
How I understand it is that Ember starts with the route (the actual url on the address bar).
From the url in the address bar, it tries to match a route from your App.Router.
Once a route is matched, it calls the corresponding Route class (extending Em.Route), here you set up the model.
This route is paired with a controller (even if you don't specify one, it's matched with a generic controller) and renders a template.
In concrete terms, if you have the following Route map:
App.Router.map(function(){
this.route('home');
});
If you are on http://localhost/#/home, it does the following:
1. Does '/home' exist somewhere in the Router map? If yes, call HomeRoute, otherwise raise an error
2. Does HomeController exist? If yes, use that, else create one that extends Em.Controller
3. Look for a template with data-template-name equals "home"
4. All calls to controller inside the template defaults to HomeController
5. Render default template, while outputting data-template-name="home" in its outlet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment