3. WHAT IS EMBER?
Aframework for creatingambitious web applications
MVC framework
Designed with productivityin mind
Inspired byCocoaand Rails
Communitydriven
4. WHY USE EMBER TO BUILD WEB APPS?
Increases productivityand reduces boilerplate
Conventions guide you down the rightpath
As your app grows the complexitystays constant
Leverages work of communityto solve common problems
Embraces the URL
7. EMBER.OBJECT
All"classes"in Ember inheritfrom Ember.Object. This is the
buildingblock for justabouteverythingin Ember and provides:
The abilityto create observers and computed properties
.getand .setwhich allow us access and trigger properties
through bindings.
10. COMPUTED PROPERTIES
Methods thatcan be accessed as properties
Allows us to propagate changes through our application
We can specifyour dependentproperties thattrigger an
update
14. ACTIONS
Triggered in templates using{{action}} or JS using.send()
Can be handled in views, controllers or routes
Handlers mustbe defined in the actions hash
Starts in controller, bubbles up through parentroutes until
handler is found
16. RUN LOOP
Asetof queues thatbatch and order work
Intelligentlyexecutes your application to maximize efficiency
and effectiveness
Have access to schedule usingEmber.run
18. EMBER.APPLICATION
Instantiate asingle instance for your application. Can optionally
pass in an elementid to use as the rootof your application.
Creates the namespace for your application.
varApp=Ember.Application.create();
19. EMBER.ROUTER
Used to define the route structure of your application. This is
done usingRouter.map.
App.Router.map(function(){
this.resource('posts',function(){
this.route('post',{path:':post_id'});//Mapsto/posts/1
});
this.resource('about',{path:'my-about-page'});
});
20. EMBER.ROUTER
Can define routes and resources. Resources can have have other
routes and resources nested under them while routes cannot.
Resources automaticallydefines index, loadingand error routes.
Routes are terminal.
21. EMBER.ROUTER
Resources willgenerate aroute, controller and template atrun
time if one matchingthe namingconvention is notfound.
For example, our posts resource willlookup or generate:
PostsRoute
PostsController
posts.handlebars
22. EMBER.ROUTE
Route objects give you controlover whathappens within a
specific route of your application. Ithas hooks thatallows you to
customize the following:
Loadingthe modelfor thatroute
Settingup the state of the controller
Customize whatis rendered
Custom logic when entering/existingthe route
Handle actions thatbubble up
Allows us to transition to other routes
24. EMBER.CONTROLLER
Controllers are designed to manage application state. Theyhave
severalproperties:
One is generated for each route
Can depend on other controllers
Holds transientstate and logic for aspecific template
Typicallyhas amodelthatrepresents an objector array
Handles actions triggered from the template
25. EMBER.OBJECTCONTROLLER
Example of an objectcontroller
App.PostController=Ember.ObjectController.extend({
hasComments:function(){
returnthis.get('model.comments.length')>0;
}.property('model.comments.length')
actions:{
cancel:function(){
this.get('model').rollback();
}
}
});
26. EMBER.ARRAYCONTROLLER
Example of an arraycontroller
App.PostsController=Ember.ArrayController.extend({
hasReadAllPosts:function(){
varunreadreadPosts=this.get('model').filterBy('isRead',false);
returnunreadPosts.get('length')===0;
}.property('posts.@each.isRead'),
actions:{
readPost:function(post){
post.set('isRead',true');
}
}
});
27. EMBER.VIEW
Able to specifythe tagName, css classes
Handles DOM events (click, keypress, etc)
Can have conditionalhtmlattributes (class, disabled, etc)
Has abackingcontroller
Notcommonlyused
29. EMBER.COMPONENT
Subclass of Ember.View, designed for reuse
Sandboxed, backingcontroller and contextis itself
Allproperties mustbe passed in viatemplate
Mustexplicitlybind externalactions to actions inside the
component
Bestplace to wrap 3rd partyplugins, i.e. jQueryplugins