A nice example, along the lines of what Scott was saying earlier, is on
jQuery's docs for jQuery.when <http://api.jquery.com/jQuery.when/>:

$.when($.ajax("/page1.php"), $.ajax("/page2.php")).done(function(a1,  a2){

    /* a1 and a2 are arguments resolved for the

        page1 and page2 ajax requests, respectively */

   var jqXHR = a1[2]; /* arguments are [ "success", statusText, jqXHR ] */

   if ( /Whip It/.test(jqXHR.responseText) ) {

      alert("First page has 'Whip It' somewhere.");

   }
});


This demonstrates two concurrent async functions (which return promises),
and an easy way of firing a callback (or in fact many callbacks) when they
are both completed.

Doing something similar with events inevitably involves some degree of
nesting or other fairly nasty constructions.




On 24 January 2012 10:01, Mariusz Nowak <mari...@medikoo.com> wrote:

>
>
> On Tuesday, January 24, 2012 10:51:39 AM UTC+1, Rob Griffiths wrote:
>>
>>  Unfortunately your slide show, whilst very cool doesn't really give any
>> insight. I'm i missing something? I saw no example or for that matter any
>> written arguments for or against promises. A slide deck without content and
>> context isn't helpful.
>>
>
> That's weird, are you sure it opened properly for you (it works well only
> on Google Chrome or Safari) ?  I often heard argument that it has too much
> content as for a slideshow but not otherwise, just this slide:
> http://www.medikoo.com/asynchronous-javascript/#/it-can-be-done-better-than-thatpresents
>  five arguments why promises is a good solution (just be sure to
> unveil all of them using right arrow or space) .. and there are over 20
> slides on promises with code examples
>
> --
>> Mariusz Nowak
>> Twitter: @medikoo
>> Github: https://github.com/medikoo
>>
>>   --
> To view archived discussions from the original JSMentors Mailman list:
> http://www.mail-archive.com/jsmentors@jsmentors.com/
>
> To search via a non-Google archive, visit here:
> http://www.mail-archive.com/jsmentors@googlegroups.com/
>
> To unsubscribe from this group, send email to
> jsmentors+unsubscr...@googlegroups.com
>



-- 
Pete Otaqui
p...@otaqui.com
+44 7949 945542

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

Reply via email to