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

The Chirpolith: Successfully Migrating A Messy App To Ember

The Chirpolith: Successfully Migrating A Messy App To Ember

Alex Rothenberg

March 12, 2018
Tweet

More Decks by Alex Rothenberg

Other Decks in Programming

Transcript

  1. 1. No clear end goal 2. Big Bang Releases 3.

    Getting more 
 complex 4. Lost momentum Aim towards a clean Ember App Small incremental releases Simplify Techniques to stay motivated Past mistakes New Guiding Principles
  2. AppRouter.map(function() { this.route('facesheet', { path: '/facesheet/:guid' }, function() { this.route('notes',

    function() { this.route('show', { path: '/:noteId' }); }); }); }); Router
  3. export default Ember.Route.extend({ async model({ noteId }) { return await

    Iora.notes.getOrFetch(noteId); }); }); Route: facesheet/notes/show
  4. export default Ember.Component.extend({ didRender() { this._super(...arguments); const bbView = new

    Iora.Views.Notes.Show({ note: this.get('note') }); this.set('_bbView', bbView); bbView.setElement(this.$()); bbView.render(); } }); Component: note-detail
  5. export default Ember.Component.extend({ … willDestroyElement() { this._super(...arguments); const bbView =

    this.get('_bbView'); if (bbView) { bbView.leave(); this.set('_bbView', null); } } }); Component: note-detail
  6. export function initialize(appInst) { const router = appInst.lookup(‘router:main'); const hashLoc

    = appInst.lookup('location:hash'); hashLoc.onUpdateURL((url)=> { if (url.startsWith(‘/#facesheet’)) { const restOfUrl = url.substr(2); router.replaceWith(`/${restOfUrl}`); } }); } An instance initializer
  7. export default Route.extend({ beforeModel(transition) { transition.abort(); const locationHash = window.location.hash;

    const bbUrl = this.bbUrl(locationHash); window.location.replace(bbUrl); } }); Route: not-found
  8. • We kept releasing behind a feature toggle
 • After

    6 weeks migrated all 32 routes … and enabled for our users Navigation was sloooow
  9. Ember Wrap Component BB View BB View A Decompose into

    a Smaller Problem BB View B BB View C
  10. Ember Wrap Component B Ember Wrap Component A Ember Wrap

    Component C Ember Wrap Component Ember Component BB View A Decompose into a Smaller Problem BB View B BB View C
  11. Ember Wrap Component B Ember Component B Ember Wrap Component

    A Ember Wrap Component C Ember Component A Ember Component C Ember Wrap Component Ember Component Decompose into a Smaller Problem
  12. • Root elements usually
 • Same resource with multiple URLs


    • Some non-restful URLs
 • Homegrown errors & pagination Our API Was Not as Conventional 
 (as We Had Thought)
  13. ...but it distracted us from deleting Backbone code. Was there

    an less complex way? Merged Successfully
  14. • Aim towards a greenfield Ember app • Small incremental

    releases • Reuse existing Backbone code • Rewrite one component at a time • Defer what you can • One Chirpolith to rule them all • Merge apps • Fake merge with an iFrame • Stay motivated Guiding Principles