Pregunta

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

Necesito un objeto user en onValue Callback

¿Fue útil?

Solución

Puede hacerlo fácilmente con combineAsArray o combineTemplate .Permiten combinar flujos / propiedades y valores constantes.Aquí hay un ejemplo utilizando combineAsArray:

Bacon.fromArray(list)
  .flatMap(function(user){
    return Bacon.combineAsArray(
      user, Bacon.fromCallback(user, 'getClients')
    )
  })
  .onValues(function(user, clients){
    // handle result here
  })

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top