Fork me on GitHub
#core-async
<
2022-04-26
>
Augustus16:04:56

How frequently do you find yourself doing the my.namespace.api + my.namespace.api.async pattern when interacting with APIs? Is it step 1 for wrapping an api? I've found I almost always want (identical) async and non async interfaces and this pattern has been the nicest to use as a user of the wrapped api. But it does kinda lead to a lot of namespaces in apps that wrap a lot of things

Ben Sless17:04:37

I usually default to an async implementation which takes a callback, and a blocking arity which delivers a promise on that callback and returns derefs it. Callbacks can easily be adapted to different async libraries

hiredman17:04:01

the api clients I have written lately end up following a aws-api like pattern where the api is kind of a single function "invoke" that takes a map describing some operation to perform and returns the result, and I often have an invoke! which returns a channel, and invoke!! which calls invoke! and then calls >!!