-
Notifications
You must be signed in to change notification settings - Fork 231
Don't route requests immediately after loading routes #467
Conversation
This allows us to load routes at the beginning of application init, making them available to the rest of the init process. Then we call `startHistory()` at the end to actually route requests.
Sounds sort-of-reasonable. Although, tests are failin’. edit: fixed |
Yeah, forgot about those, just pushed a new commit. If you think this is a good way to handle it, Brunch probably needs an update to the boilerplate. |
Not fond of this. The user shouldn't have to access I wouldn't mind if you placed |
@mehcode I'm not sure which We could also add a |
Oh right... the application doesn't call initialize implicitly. Well... should we do something like: class Application
constructor: (options) ->
@initialize options
# Throw error messages if all components aren't started perhaps?
@router.startHistory() Any reason not to @paulmillr / @molily ? I like the sanity checking it provides if someone forgets to init the composer or something. |
I had async |
That logic probably belongs in the application under |
I think we can get consensus on this by adding @mehcode ? |
Agreed. My votes goes for |
We ran into trouble trying to use the "url" view helper in Brunch for named routes in our layout. This helper depends on the router (obviously), but the layout is being initialized in
@initLayout()
, which comes before@initRouter
in the initialization sequence.I think the best solution is to load routes at the beginning of application init, making them available to the rest of the init process. Then we call
startHistory()
at the end to actually route requests.This will require an adjustment to the Chaplin init sequence. With this patch, our
application.coffee
file in Brunch now looks like this: