Closed jcferrer closed 8 years ago
Hey JC. Sorry, that's completely my fault in documentation. pipes.play() actually executes asynchronously and so the console.log() won't log anything. The correct thing to do in this case would be to add a fitting to the end of the pipe that executes the console.log(). I'll update the docs.
That said, perhaps I should look into allowing the client to either pass an optional callback to the play() function or return a Promise that can be waited for so a client can respond outside of the pipe. What do you think?
Scott,
I was expecting it be asynchronous but I didn't see any callback function in the signature. Callback or promise would work.
Thanks for the help.
Ok. But before I look into adding code for that... Would just adding an in-line fitting before calling play() work for you as well?
pipe.fit(function(context, cb) {
console.log(context.output);
cb(null, context);
});
pipes.play(pipe, context);
It should offer the same behavior as what you're expecting and I can just add some documentation for it.
Scott,
Yes that would work also. Thanks JC
Great. So for now, I've updated the examples to work correctly. I'll also consider adding a Promise, callback, or event for when the pipe finishes execution.
I am trying to use the geocoding example shown in the documentation. Geocoding works fine, but I cannot find a way to get the final results from the context.output property. It seems to be undefined. I can see it in the debug output, but
console.log(context.output)
returns undefined.config/default.yaml
app.js