PR: Promises Implementation#87
PR: Promises Implementation#87ydaniv wants to merge 6 commits intojulianshapiro:masterfrom ydaniv:promises
Conversation
|
Rejection reasons should always be The fact that you can turn on promises library-wide, instead of having to do +1 on bad calls returning rejected promises (instead of e.g. throwing); that is how it should work. |
|
@domenic thanks!
Agree. My intention was to allow the user to continue chaining from the rejection handler, but following the spec is better. I'm still thinking we should make the default |
|
I'm torn on Would it be possible to keep it |
|
Make sure to return the promise object, not a deferred. That is, there should be no resolve or reject methods. |
|
@mikaelkaron jQuery's Moreover, IMHO it looks like you wouldn't want to touch the DOM after you start an animation, and actually rather, in most cases, defer actions till the end. @domenic but of course. Now I'm returning the result of |
|
@domenic, @mikaelkaron, @ydaniv, @Hiswe. Thank you so much everyone. It is exciting to see this implemented so thoughtfully. Three responses:
(Although certainly a tangential point, does anyone have additional thoughts on this last point? Where might not returning the element set in a non-jQuery environment harm the user's workflow?) |
|
Hang on.. Am I crazy when I remember a I don't think I am as http://api.jquery.com/promise/ is there. Could we make use of it? And by extension... if we're using the jQuery
I wonder if |
|
@mikaelkaron that's brilliant! I never knew you can just do There's still a problem with Zepto not having a deferred/promise implementation, but I think we can live with that. Of course, we still check for native-like Promise object on the The rejected handler is sending a @julianshapiro I think that wraps it up. |
Changed Velocity.defaults.promsie to true; Set Velocity.defaults.promsie to false if found jQuery/Zepto
|
As a bonus, I would not be surprised if this would allow you to stack velocity and jQuery animations after each other (and probably anything pushed on the Before we merge this I was hoping to hear from @domenic (or as we call him here, Mr Promise) about having PS. Come to think of it, you could produce some really funky stuff by combining promises from various queues in jQuery to coordinate animation by just using something like |
|
I don't really see any downside to having the element (or And yes, using |
|
@mikaelkaron Technically you could stack velocity and jQuery animations since you can cast jQuery Deferreds with I think jQuey animations are already thenable, so you don't have to worry about it as much... |
|
Btw. Ran across this in my rss feed today, 2K compressed promises anyone? |
|
Great find. We can recommend this in the docs. By the way, promises will be implemented very shortly. Sent from my phone.
|
|
Btw, thanks for being so attentive with all the tickets, must be a pain to keep track of all things velocity. Really appreciate it. |
|
It's my pleasure. Thank you so much for contributing, Michael. It's when someone like you takes interest in the project that I get motivated to continue improving it. |
|
No its my pleasure to help just a little. Anyways, instead of messing up the thread I'll just leave it alone with one last comment of "great job", and I'm sure many others around here would concur. |
README.md bower.json component.json jquery.velocity.js jquery.velocity.min.js package.json velocity.ui.js
|
This has become too messy in git terms. Will open a new PR. |
|
Please update both Velocity and the UI pack. Promises are now implemented: http://velocityjs.org/#promises |
This is a first attempt. Still not quite sure about API design.
What's in there:
velocity.defaults.promise:falseby default and if set totrueit will always return a promise.options.promise: if set totruethen a promise is returned for that call.$.fn.velocity()calls and also using an action, e.g.slideUp.$.fn.velocity()return a rejected promise.velocity.Promiseto a constructor that behaves the same.Example: http://jsfiddle.net/faa8e/
Not in there: