Skip to content

Instantly share code, notes, and snippets.

@mikeric
Created November 19, 2013 02:00

Revisions

  1. mikeric created this gist Nov 19, 2013.
    12 changes: 12 additions & 0 deletions backbone-collection-promises.coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    # synchronous ajax calls (one at a time, then
    # start the next one, etc. then do something)

    sessions.fetch success ->
    rooms.fetch success ->
    do_something

    # async ajax calls (all at the same time, then
    # do something when all are finished)

    $.when(sessions.fetch(), rooms.fetch()).then ->
    do_something