0
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

Huangism
  • 16,278
  • 7
  • 48
  • 74
redexp
  • 4,765
  • 7
  • 25
  • 37
  • 1
    one ways is to add map like `return Bacon.fromCallback(user, 'getClients').map(function(val){ return {user: user, clients: val} })` – redexp Jul 31 '14 at 15:31
  • Related: [How do I access previous promise results in a .then() chain?](http://stackoverflow.com/q/28250680/1048572) – Bergi Jan 31 '15 at 10:59

1 Answers1

0

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
  })
attekei
  • 491
  • 4
  • 10