Promises with Q.js

client = require './client_promises' 

client.login('davide', 'pass').then ->
  client.getPosts('alberto')
.then (posts) ->
  cur = Q()
  promises = posts.map (post) ->
    cur = cur.then -> client.countPostLies(post)
  Q.all(promises)
.then (results) ->
  client.logout()
.catch (e) ->
  console.error 'should handle error here'

Comments

h