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

How i learned to stop worrying and love the router

Embed Size (px)

DESCRIPTION

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

Citation preview

Page 1: How i learned to stop worrying and love the router

How I learned to stop worrying and love the Router

1

Page 2: How i learned to stop worrying and love the router

5 Tips2

Page 3: How i learned to stop worrying and love the router

Routes are Magic

3

# 1

Page 4: How i learned to stop worrying and love the router

Routes are Magic

4

# 1

IT ALL Starts with Templates

Page 5: How i learned to stop worrying and love the router

Routes are Magic

5

# 1

ALMOST ALL BOILERPLATE GOES AWAY As long as you Follow The

Ember naming conventions

Page 6: How i learned to stop worrying and love the router

Routes are Magic

6

# 1

With Router v1: 282 loc

Page 7: How i learned to stop worrying and love the router

Routes are Magic

7

# 1

Today: 32 loc

Page 8: How i learned to stop worrying and love the router

WTF Router?

8

# 2

its hard to know what’s going on WITHOUT

LOG_TRANSITIONS = TRUEFor Console.log output when the router transitions between States

Page 9: How i learned to stop worrying and love the router

WHERE AM I?

9

# 3

The router will tell you. It sets a

currentPathproperty on you application controller

Page 10: How i learned to stop worrying and love the router

Template w.no Route?

10

# 4

Use the Handlebars

{{render sidebar}}tag - IT WILL wrap Your template in a view/Controller Pair wit

Page 11: How i learned to stop worrying and love the router

Routes ARE STATES

11

# 5

but the ROUTER is not a STATE MANAGER (anymore)

Page 12: How i learned to stop worrying and love the router

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

Page 13: How i learned to stop worrying and love the router

Questions

13

GitHub: @MIKEGRASSOTTItwitter: @mgrassotti