willconant / flow-js

Javascript Library for Multi-step Asynchronous Logic
MIT License
302 stars 15 forks source link

`MULTI()` does not apply `resultId` to the results array #4

Closed KrofDrakula closed 12 years ago

KrofDrakula commented 12 years ago

We're using Backbone models and collections in combination with flow-js to sync API calls. As per your example, MULTI() takes a parameter that allows it to identify a result when multiple async methods are required to complete before continuing. However:

flow.exec(
  ->
    aCb = @MULTI 'a'
    bCb = @MULTI 'b'
    aModel.fetch success: aCb, error: aCb
    bModel.fetch success: bCb, error: bCb
  (results) ->
    console.debug results # => [Array[2], Array[2]]
)

The code returns a numerically indexed array instead, so your example of results['a'] and results['b'] return undefined.

KrofDrakula commented 12 years ago

Ah, nevermind, this issue exists only in the published 0.2.2 version, not the currently published master. Mind updating the NPM package?