[API Break] .sequence() and .chainify() now handle multiple `.fulfill()` arguments correctly

已查看 5 次
跳至第一个未读帖子

AJ ONeal

未读,
2010年9月7日 13:11:262010/9/7
收件人 futures-j...@googlegroups.com
API docs have been updated on github.

Whine about it now or forever hold your peace. Suggestions welcome. This change 


Futures.sequence

This change removes functionality that was most likely not even used and makes it more useable with nodejs, etc.
For many users this requires no change to code (since `index` and `arr` were fairly useless in the first place)

WAS
Futures.sequence(function (fulfill) {
    fulfill("one argument");
  })
  .then(function (fulfill, result, index, arr) {
    // do stuff
  });

NOW
Futures.sequence(function (fulfill) {
    fulfill("one", "two", "three");
  }).then(function (fulfill, one, two, three) {
    // one === "one"
    // two === "two"
    // three === "three"
  });


Futures.chainify

A one-liner fixes old code

WAS
Futures.chainify(providers, {
  consumer1: function (data, params) {
    // do stuff with `data`
  }
})

NOW
Futures.chainify(providers, {
  consumer1: function (results, params) {
    var data = results[0];
    // do stuff with `data`
  }
})

AJ ONeal

回复全部
回复作者
转发
0 个新帖子