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
Async transitions #2740
Async transitions #2740
Conversation
Let's merge this thing. |
Oh, yes! Great work. |
@machty is doing god's work. bows. |
Does this break existing apps that rely on the |
Oh yes, this is a game changer for my app 👍 |
Oh yeah baby, please merge this goodiness |
@tomdale Take a look at https://github.com/emberjs/ember.js/pull/2740/files#L5R260 I think this will Just Continue to Work for most people's apps; edit: One other criterion of |
Worth discussing: I removed the global If you really want to define default error handling that will fire for ALL routes, you can do as follows
This seems more intuitive (albeit new) to me than making using of |
@machty should the ApplicationRoute's implicitly error handler, simply transition to the default FailureRoute ? |
@stefanpenner the |
@machty I personally agree your change. In our app, having a single The only thing I would like to see is the error bubble up. |
@workmanw @stefanpenner it means that We could also not put it on the events hash and have it still bubble, but then that's inconsistent with the only other thing on Routes that bubble: events. |
@stefanpenner Agreed, there is certainly nothing wrong with a catch all, but what I was trying to say is having a catch all as you're only option for catching stuff is smelly. Which is how it currently works (AFAIK). If we could bubble errors, your catch all could live at the @machty What if instead of bubbling with events and Ember.Route = Ember.Object.extend({
// ...
error: function(error, transition) {
if(this.parentRoute) this.parentRoute.error(error, transition);
}
}); |
@workmanw it's presently non trivial to get the parent route (involves a loop on router.js's internal structure). I also don't want to weirdly get stuck between inheritance-based polymorphism and event-based polymorphism. Seems like that'll just be confusing. |
@machty, Yeap. That's fair. |
Seems like we're going to put |
@machty Thanks for all you're hard work. |
Your welcome! |
Awesome! This will make a lot of things way more elegant in our app. Great work Alex! |
Just pushed a new version with tons of documentation and bubbling |
Awesome! |
@machty 💃 |
Can we/should we expose a logging hook, for debugging what the router is doing? It will make any issues people run into hella easier to debug. |
I tried updating an app with a complex router and found a bug with how params are being handled when you have multiple dynamic segments. Demonstration here: http://jsfiddle.net/DCrHG/77/ It may be related to this code: Or perhaps the params were previously being filtered before passed to model? |
I can't even begin to explain how excited I am about this, being able to halt transitions if an object is dirty is going to remove so much ugly code from my codebase 🍺 |
@lukemelia I'll look into that bug shortly, surprised router.js test suite wouldn't have caught it. router.js has the |
I'm free all day. Where/when yall wanna meet? |
This PR looks solid and is so very much appreciated, @machty. I think my only concern is semantic: the purpose of I propose refactoring |
Previous iterations of this facelift had |
agreed, there are already sooo many vocab things to remember :/ like render outlet into blah template On Sun, Jun 16, 2013 at 2:52 PM, Alex Matchneer notifications@github.com
|
Ember's API already has quite a surface area, yet it remains accessible because method names are fairly consistent with their intended usage. I think that naming methods based upon their order of operations, rather than their intentions, is a break from a formula that's worked well so far. I would argue that the challenge isn't to limit vocabulary, but to ensure that new methods remain semantic and consistent. I know naming issues can be a bit subjective, so I try to think from the perspective of someone new to Ember. Would they find it more clear to learn that you verify the accessibility of a route in |
When you ask the question "which method would you use to verify the accessibility of the route, a) |
What about |
No, people would confuse that with enter/exit, or some other lifecycle hook not specific to model resolution. |
|
||
`error` events that bubble up all the way to `ApplicationRoute` | ||
will fire a default error handler that logs the error. You can | ||
specify your own global defaut error handler by overriding the |
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.
spelling: "defaut"
Apart from above discussion, I have one thing to ask for: after merging this, can we have some time before releasing another rc version? This is a big change and although it is awesome, I'm pretty sure that we will hit some problems soon, with next rc pushed quickly it will be hard to do any changes that need API changes. |
@drogus tis the plan |
This is the Ember side of tildeio/router.js#19 All set, just keep in mind that there is probably more discussion to be had over the `beforeModel` and `afterModel` hook names, which might change before RC6.
Woot! This is a big win for ember. Nice work @machty! |
🚢 🚢 this is awesome, let's get an RC out!! =) |
Thanks for the hard work @machty. I'm sure an embercast would be helpful. Cheers |
@jonnii we wil give this merge a few days to settle before another RC. If all goes well, we will see another RC in a weeks time. |
Just upgraded Ember in my (fairly substantial) app and everything still works, now to start deleting lots of code which is no longer needed! Awesome stuff @machty 🍻 |
Relief! |
Just upgraded my quite substantial app too. Only a couple of gotchas completely unrelated to the code itself
Bravo @machty. This is awesome. |
@bradleypriest we ran into the same issue with ember-data, I have some time tomorrow planned to look into it. Hopefully it will lead to a fix. |
@bradleypriest What do you think is a good solution / pattern for preventing the willTransition gotcha? In a similar case, I opted for disabling the |
@bradleypriest @stefanpenner I've had an open PR in ED about the ManyArray issue for a while emberjs/data#957 |
@machty yep, I'm calling |
@machty Is there are a pattern for returning a promise object but not waiting for it to resolve? I'm currently using model: function(params, transition) {
comments = transition.resolvedModels.post.get("comments")
Ember.run(comments, 'resolve', comments)
comments
} But I'm not sure if there are other promises this is resolving early within ED |
@bradleypriest promises on collections and models will be removed in ED in the future |
@bradleypriest confirm what @drogus said. It might just be best to reopen the various ember data Model classes and set their |
Async-ify the router.
API guide
possibly out of date but live examples
router.js PR
Likely to make it into RC6