Hello. After study core.async
and some async API's I end up with this "recipe" to turn an sync API into a async one (in terms of interface).
I would like a feedback about this, if it's clearly wrong, something that could be done in a better way. Anything 🙂
https://gist.github.com/souenzzo/ee4f1ef4124d21993e0c2e55d4626ce9
I'm not convinced regarding the return channel. It's essentially like passing a promise to a function. It's passing by-ref instead of by value.
Why not return a thread
or go
which are already channels?
The exception handler is a good idea
To be honest, IDK. I saw it in some place and just reproduced the pattern. Many other places accept a xform This night I will play and prototype with my sample APIs and try to remove the chan from the params
A xform isn't a good fit here either, imo
You want simple composable APIs
@ben.sless you have some API to use example?
An api call returns a thing. In what context is it appropriate to apply a transducer to one thing and not a sequence of things? In terms of converting synchronous to async calls, this post has a good example in the end http://danboykis.com/posts/things-i-wish-i-knew-about-core-async/ When you return a channel you can naturally use stuff like async/merge