-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Remove transition.wait, use callbacks instead #654
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
Conversation
be00965
to
c67e0b9
Compare
not that I dislike promises, but this is great 👍 |
modules/utils/Transition.js
Outdated
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.
I know 3
is the magic number, but what is this 3
all about?
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.
oh nvm, args length, I was thinking we were collecting hooks or something ...
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.
I'll make the comment clearer.
File size is 7.7kb now, saves us ~3k. I think that and the other things you've noted are worth this change: transition.wait(promise());
promise().then(callback); I can't find an objective reason the |
modules/__tests__/Router-test.js
Outdated
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.
typo
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.
Thanks :)
I didn't realize we can check arity. I'm on board with this! |
This commit also removes our dependency on when.js and introduces a callback argument in transition hooks. Users are expected to call callback(error) when they're finished doing async stuff. If they don't have a callback in their argument list, we automatically call the callback for them for backwards compat. Fixes #273 Fixes #631
c67e0b9
to
c6ed6fa
Compare
Remove transition.wait, use callbacks instead
@rpflorence @gaearon We should cut another minor release with this change. Anything else you wanna get in? |
@mjackson I'd love to see
|
I'll get a release out today, it's a breaking api change so we'll be at 0.12 |
So how would you handle a transition.redirect() when doing async/promise calls? Seems that the redirect gets ignored when trying to do something like this:
@mjackson Thanks for your hard work! Looking forward to future releases |
Sorry if I was not clear in my above question - since the removal of .wait(), what would be the equivalent to this?
|
I think something like statics: {
willTransitionTo: function (transition, params, query, callback) {
checkAuthAndStoreItSomewhere().then(function (auth) {
if (auth == null)
transition.redirect('login');
}).then(callback);
}
} |
Thanks @gaearon - this occurred to me this morning..just needed some sleep :) I appreciate the quick response and the hard work...Looking forward to .13 release so I can fully support ES6 in React! |
This commit also removes our dependency on when.js and introduces
a callback argument in transition hooks. Users are expected to call
callback(error) when they're finished doing async stuff. If they
don't have a callback in their argument list, we automatically call
the callback for them for backwards compat.
Fixes #273
Fixes #631
I have mixed feelings about this PR. Part of me wishes that everyone would get on the same page, realize how cool promises are, use webpack, and be happy. But hey, at least we get: