Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building Apps with Ember (a postmortem)

Sean
July 26, 2013

Building Apps with Ember (a postmortem)

Sean Creeley (https://twitter.com/screeley) will be postmorteming his recent experience rewriting the Embedly user app in Ember. Sean will talk about what Ember is good at doing, what it's not so great at, code patterns, and ways to structure your apps. He will go over useful Ember features that aren't documented well and end with an overview of a recent tutorial series he and his colleagues published on Ember development on the Embedly blog (http://blog.embed.ly/tagged/emberjs).

Sean

July 26, 2013
Tweet

More Decks by Sean

Other Decks in Programming

Transcript

  1. @screeley Angular is faster than Ember, here's the link to

    prove it: bit.ly/11mNonE @screeley Backbone is 1,500 lines of code, Ember has 27,000. Talk about bloat. @screeley neckbeard, neckbeard, neckbeard. I hate you.
  2. TEMPLATES <div class="row"> <div class="large-12 columns"> {{outlet}} </div> </div> <h1>Welcome

    to Dolphin!</h1> <p>Helping Dolphins become the smartest species since 2013</p> application.handlebars index.handlebars
  3. MODELS Dolphin.CompanyTeamRoute = Em.Route.extend({ model: function(){ return [ {name: 'sean'},

    {name: 'kawandeep'}, {name: 'andy'}] } }); <ul> {{#each controller}} <li>{{name}}</li> {{/each}} </ul>
  4. VIEWS Dolphin.CompanyTeamView = Em.View.extend({ didInsertElement: function () { // fade

    images in. this.$().find('img').animate({ opacity: 1 }, 2000); } });
  5. ARRAYS var arr = Em.A(["a", null, "b", "c"]); arr.contains("a"); //

    true arr.compact(); // ["a", “b”, "c"] arr.without("a"); // ["b", "c"] arr.some(function(){}); arr.every(function(){}); arr.map(function(){}) arr.reduce(function(){}, 0) arr.forEach(function(){}) arr.reject(function(){})
  6. { "blogs": [ { "id": 1, "name": "Embedly Blog" },

    { "id": 1, "name": "Embedly Blog" }, .... ] } /api/blogs
  7. {"users": [ { "id": 1, "name": "Sean", "email": "[email protected]" },

    { "id": 2, "name": "Kawandeep", "email": "[email protected]" }, .... ]} /api/users
  8. App.deferReadiness(); // Wait for all the javascript files to load.

    $(document).ready(function(){ App.User.current(function(user, profile, organizations){ // Set everything else up. App.set('user', user); // Will start everything up. App.advanceReadiness(); }); });
  9. var Clip = Em.Namespace.create(); Clip.Copy = Em.View.extend({ didInsertElement: function(){ this.$().attr('data-clipboard-text',

    Dolphin.get('org.api_key')); var clip = new ZeroClipboard( this.$().get(0), { moviePath: "/scripts/vendor/zero/zero- clipboard.swf" }); } });
  10. App.OrganizationRoute = App.AuthedRoute.extend({ model: function(){ var promise = Em.Deferred.create(); App.Organization.find(

    {slug:params.slug}).then(function(results){ App.set('org', results.objectAt(0)); promise.resolve(results.objectAt(0)); }); return promise; } });
  11. App = Ember.Application.create({ LOG_STACKTRACE_ON_DEPRECATION : true, LOG_BINDINGS : true, LOG_TRANSITIONS

    : true, LOG_TRANSITIONS_INTERNAL : true, LOG_VIEW_LOOKUPS : true, LOG_ACTIVE_GENERATION : true }); {{debugger}} {{log controller}}