$30 off During Our Annual Pro Sale. View Details »

How I learned to stop worrying and love the router

How I learned to stop worrying and love the router

5 Tips on using the new router that shipped with ember v1.0.0-pre.4, presented to ember nyc meetup on 2013/01/24

Michael Grassotti

January 24, 2013
Tweet

More Decks by Michael Grassotti

Other Decks in Technology

Transcript

  1. How I learned to stop worrying and love the Router

    1
  2. 5 Tips 2

  3. Routes are Magic 3 # 1

  4. Routes are Magic 4 # 1 IT ALL Starts with

    Templates
  5. Routes are Magic 5 # 1 ALMOST ALL BOILERPLATE GOES

    AWAY As long as you Follow The Ember naming conventions
  6. Routes are Magic 6 # 1 With Router v 1:

    282 loc
  7. Routes are Magic 7 # 1 Today: 32 loc

  8. WTF Router? 8 # 2 its hard to know what’s

    going on WITHOUT LOG_TRANSITIONS = TRUE For Console.log output when the router transitions between States
  9. WHERE AM I? 9 # 3 The router will tell

    you. It sets a currentPath property on you application controller
  10. Template w.no Route? 10 # 4 Use the Handlebars {{render

    sidebar}} tag - IT WILL wrap Your template in a view/Controller Pair wit
  11. Routes ARE STATES 11 # 5 but the ROUTER is

    not a STATE MANAGER (anymore)
  12. Routes ARE STATES 12 # 5 Create Record on enter

    (via model Hook) Save: Register DidCreate CallbaCK TheN Commit DidCreate: Transition elsewhere EXIT: Rollback Unsaved Model
  13. Questions 13 GitHub: @MIKEGRASSOTTI twitter: @mgrassotti