Permalink
Browse files

changed router to observe return values from routers so that the even…

…t can be processed before being returned to the navigator.
  • Loading branch information...
1 parent 1403295 commit 0f7da0874028143412fe8f2c4c2772aa07405f09 @neonstalwart committed Jun 29, 2011
Showing with 6 additions and 4 deletions.
  1. +6 −4 lib/navigation/Router.js
View
@@ -13,7 +13,8 @@
define([
'dojo/_base/array',
'compose',
-], function (d, compose) {
+ 'promise'
+], function (d, compose, promise) {
'use strict';
// this is used as an event listener component
return compose(function NavigationRouter() {
@@ -23,14 +24,15 @@ define([
var target = event.target;
if (target && target.match) {
- d.forEach(this._routes, function (route) {
+ // allow the routers to process the event before its returned to the navigator
+ return promise.all(d.map(this._routes, function (route) {
var args = target.match(route.route);
if (args) {
args.unshift(event);
- route.handler.apply(null, args);
+ return route.handler.apply(null, args);
}
- });
+ }));
}
},

0 comments on commit 0f7da08

Please sign in to comment.