I don't know when tasks.js will be "usable" (ie generators supported)
but probably it's a very good solution to solve all the async (and
resync) issues I had doing https://github.com/Ayms/node-Tor where
unexpected and unpredictable things as well as performances reasons
forced me to use [do_not_wait, setTimeout, clearTimeout,...] which makes
part of the code look like a mess and that I found not easy at all to
synchronize.
Le 13/11/2012 11:43, David Bruant a écrit :
Le 10/11/2012 03:14, Brendan Eich a écrit :
David Bruant wrote:
Personally, to synchronize different async operations, I've never
read code more elegant than what Q.all offers.
What about task.js's join?
https://github.com/mozilla/task.js/blob/master/examples/read.html#L41
I feel it's pretty much equivalent. Maybe slightly less verbose. I'd
write the same code with promises as:
Q.all(read("sleep.html"), read("read.html")).then(function(f1, f2){
out.innerHTML += "sleep.html: " + (f1.responseText.length) +
"\n";
out.innerHTML += "read.html: " + (f2.responseText.length) + "\n";
});
Generators + promises = tasks ;-)
It took me several months to understand the value of tasks.js and then
I loved the idea (though I haven't used it because of the lack of
generators in platforms). The code you linked to leaves me somehow
uneasy, because it looks like sync code while it's async. Promises
have this advantage that they make clear what's sync and what's async.
But maybe I also need to step out of my comfort zone for this case...
What's the error forwarding/handling story for tasks?
David
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss
--
jCore
Email : [email protected]
Web : www.jcore.fr
Webble : www.webble.it
Extract Widget Mobile : www.extractwidget.com
BlimpMe! : www.blimpme.com
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss