-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Allow multiple calls to App.Router.map
#2485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -234,15 +234,27 @@ function doTransition(router, method, args) { | |
|
|
||
| Ember.Router.reopenClass({ | ||
| map: function(callback) { | ||
| var router = this.router = new Router(); | ||
|
|
||
| var dsl = Ember.RouterDSL.map(function() { | ||
| this.resource('application', { path: "/" }, function() { | ||
| callback.call(this); | ||
| // Make sure the mapCallbacks exists | ||
| if (this.mapCallbacks == null) { | ||
| this.mapCallbacks = []; | ||
| } | ||
| this.mapCallbacks.push(callback); | ||
|
|
||
| var router = this.router, | ||
| self = this; | ||
| if (this.router === undefined) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @machty Unless I'm misunderstanding you, I've already changed the behavior here to not discard the Apologies for the confusion, I'm in #emberjs if a direct chat resolves this more easily |
||
| router = this.router = new Router(); | ||
| } | ||
|
|
||
| var dsl = Ember.RouterDSL.map(function() { | ||
| this.resource('application', { path: "/" }, function() { | ||
| for (var cb_i = 0, cb_l = self.mapCallbacks.length; cb_i < cb_l; cb_i++) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you factoring out cb_l? I think it makes the for loop longer/harder to read. |
||
| self.mapCallbacks[cb_i].call(this); | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| router.map(dsl.generate()); | ||
| return router; | ||
| router.map(dsl.generate()); | ||
| return router; | ||
| } | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not define it as a class variable on line 235.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for reference: #2892