Question

Bacon.fromArray(list)
    .flatMap(function(user){
        return Bacon.fromCallback(user, 'getClients');
    })
    .onValue(function(clients){
        // need `user` object some how
    })
;

Need user object in onValue callback

Was it helpful?

Solution

You can do it easily with combineAsArray or combineTemplate. They allow combining streams/properties and constant values. Here is an example using combineAsArray:

Bacon.fromArray(list)
  .flatMap(function(user){
    return Bacon.combineAsArray(
      user, Bacon.fromCallback(user, 'getClients')
    )
  })
  .onValues(function(user, clients){
    // handle result here
  })
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top