core-async

souenzzo 2021-06-29T02:56:36.106Z

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

Ben Sless 2021-06-29T10:57:55.106300Z

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

souenzzo 2021-06-29T11:52:22.106500Z

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

Ben Sless 2021-06-29T11:59:31.106700Z

A xform isn't a good fit here either, imo

Ben Sless 2021-06-29T12:00:03.106900Z

You want simple composable APIs

souenzzo 2021-06-29T16:55:27.107100Z

@ben.sless you have some API to use example?

Ben Sless 2021-06-29T16:59:43.107300Z

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