Hey Juha,
I've implemented fromMultiCallback, viewable here:
https://github.com/laser/bacon.js/blob/features/from_multi_callback/src/Bacon.coffee#L126
I realized just now, though, that this approach suits asynchronous
operations being passed callbacks having an arity 1 only. For example:
The callbacks passed to methods "post" and "get" on an Express route
(
http://expressjs.com/4x/api.html#app.route) have an arity of greater
than 1; using Bacon.fromCallback or Bacon.fromMultiCallback would end
up getting the programmer a stream of events giving access to only the
first argument passed to the callback.
I'll go ahead and create a PR for the fromMultiCallback work I've
done, but, as it currently stands - I'm not seeing a good way to use
Bacon with the Express route-handlers! Do you have any thoughts on the
matter?
Once again - I'm looking to do something like:
// original
//
app.get('/foo', function(req, res) {
res.send(req.params.something);
});
// desired
//
requests = Bacon.doSomethingRad(app.get, '/foo')
requests.onValues(function(req, res) {
res.send(req.params.something);
});
// ...but if that were supported, what would we do when...
//
Bacon.doSomethingRad(function(callback) {
setInterval(function() {
callback(['x', 'y', 'z'], [1, 2, 3]);
}, 500);
});
Take care,
Erin