chaplinjs/chaplin — pull request #719 by Sija (2013-11-29 01:10:14+00:00)
Title: Fix Dispatcher#currentRoute being initialized too early

Hello!

I'm developing an app which uses promise based `beforeAction` filter.

While debugging I've found that when using promises, `Dispatcher#currentRoute` is set (dispatcher.coffee:96) before the promise has a chance to be resolved (dispatcher.coffee:150), which leads to a "false positive" on check (dispatcher.coffee:133) and finally manifests in the UI as inability to click on the link (which leads to a controller with `beforeAction` returning a promise) more than once.

After changing a route, which in turns modify `Dispatcher#currentRoute`, the check from line 133 doesn't apply anymore so user have another "one-shot" click before going back the same route ;)

Proposed solution moves initialization of `Dispatcher#{current,previous}Route` one level lower, where it can safely "wait" for a promise to resolve.