-
Notifications
You must be signed in to change notification settings - Fork 23
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
toDeferred suggestion #31
Comments
The idea sounds good. Dependency on jQuery is not acceptable in the core though. Should we consider a more generic asPromise method instead, without ext deps? The jq deferred based impl can of course be provided as a plugin too. -juha-
|
What do you think about Bacon.$.toDeferred(obs) in 'bacon.jquery' ? Also, there're several platform-dependent implementations of Promises/A (WinJS, 'native' Promises @ webkit, etc..) |
Adding toDeferred in bacon.jquery sounds like a good idea. In fact I'd rather extend the Observable prototype so that Don't know yet what to do with all the different promise specs and implementations :) |
What about putting |
Yes, that's exactly what I meant :) |
So #32 was merged! Still, we should 1) update README 2) add tests 3) refactor implementation: what is withHandler doing there? Why not plain subscribe? |
Ok will do. Surely, it must be |
Just checking: would you expect |
Not at all =). Ajax Stream consists only of one event value though. I think there's need for more tests e.g. using |
And... it works as I expected=) var D = Bacon.sequentially(100, [1,2,3]).toDeferred();
D.progress(function(x){console.log("P",x)}) P.S. For |
I already removed the The |
Yup! But there's should be progress fn call for each value in the stream to satisfy Deferred specs). What do we need to do then? |
For instance, if we ditch var log = console.log.bind(console)
// async sequence values
seq = Bacon.sequentially(100, [1,2,3]).toDeferred()
seq.progress(log) // 1 - 2 - 3
seq.done(log) // 3
// 'immediate' values
immediate = Bacon.fromArray([1,2,3]).toDeferred()
immediate.progress(log) // 3
immediate.done(log) // 3
//ajax
ajax = Bacon.$.ajax({url:"http://myurl"}).toDeferred()
ajax.progress(log) //result
ajax.done(log) //result All except |
Hmm.. Deferred specs? What are they and where? |
nevermind, just plain jquery docs for dfd. http://api.jquery.com/category/deferred-object/ |
Look at this example -- http://codepen.io/wolfflow/pen/fcmzl/. Despite some progress event problems with |
Sometimes, you need to turn your Bacon observable back to $.Deferred (/Promise/etc.).
(e.g. in order to provide a solution for jQuery users which are not familiar with Bacon =) ) and, AFAIK, RxJS has smth similar.
A method suggestion gist is here:
https://gist.github.com/wolfflow/b0a7a9a37938f80a9c6d
The text was updated successfully, but these errors were encountered: