Covers building Ember.js apps with a focus on application structure, and how responsibilities are divided, and how to manage complexity as your app goes from small to large.
Mobile Cross-platform, mobile-style UI with offline support, wrapper in PhoneGap 5 Dashboard Simple one-pager for desktop/tablet, previously Rails + jQuery/ajax Editor Rich desktop-style app for desktop/tablet, previously a Sproutcore app
■ If you’ve never considered yourself a professional UI Engineer, you’re about to become one. ■ Long-lived state ■ UI responsiveness 10 Lay of the Land: This is UI Development
13 Overall app data flow Router / State Manager Controller Controller View View View View Model Model Model Model Data flows down from models via bindings Events flow up from view layer to the router Router updates models & controllers based on events
15 Router / State Manager Controller Controller View View View View Model Model Model Model Models: Usually serialized/deserialized to/from API API Client
16 Router / State Manager Controller Controller View View View View Model Model Model Model Models: Should not depend on controllers, views or other app state
■ To work with the router, a model class should: ■ implement find(id) ■ implement then(success, failure) (promise pattern) 19 Models: Working with router
■ ember-data is an ORM for Ember ■ Store + Adapter + Serializer ■ DS.Store implements an Identity Map ■ REST Adapter ■ Work in progress; will be merged into ember.js 21 Models: ember-data
Controllers: Ember.ObjectController ■ Transparently proxies missing properties and methods to the object set as its content property ■ Destroyer of boilerplate 26
Views: Rendering is usually handled with templates 36 Router / State Manager Controller Controller View View View View Model Model Model Model Handlebars
Views: Use with a single controller ■ Should bind to properties of one controller ■ If you need data from elsewhere, bring it into this view’s controller using connectControllers() as discussed above 40
Data-binding caveat ■ Bound properties, using computed properties or bindings, are very powerful ■ Two-way bindings can lead to unexpected behavior and bugs and are often unnecessary 50
Router: Tips ■ It can get large. Break it up into separate files, one per state. ■ Be careful with asynchronicity in the router event handlers. ■ Delegate to separate state managers where possible. 52
53 Overall app data flow, reprise Router / State Manager Controller Controller View View View View Model Model Model Model Data flows down from models via bindings Events flow up from view layer to the router Router updates models & controllers based on events
Q & A Follow me @lukemelia Some examples appear courtesy of my company, Yapp (which is hiring now or soon). Creative Commons photo credits: flickr.com/photos/fictures/4596895 54