The problem with using bare callbacks is that there's no way for the invoked callback to exert backpressure, except by blocking or passing in a CPS-style callback to the callback, neither of which is ideal. If you're looking for a "neutral" choice, I'd suggest an infinite lazy-seq over callbacks. If you absolutely need it to be async, something like Manifold might be warranted, in that it allows people to consume it however they like (though they will have to be at least a little familiar with Manifold to do so).
Zach On Monday, June 1, 2015 at 12:18:19 PM UTC-7, Christopher Small wrote: > > Greetings > > I imagine most of us here would rather use core.async channels over > callbacks in their application code, particularly with more complicated > applications. But is it okay/preferable for Clojure libraries to force > their users to use core.async channels as part of an API (an event channel, > for example)? > > As much as I love core.async, I can't help but wonder whether sticking > with callbacks for an API isn't a simpler/better design strategy. It's easy > enough to drop messages on a channel in a callback, and this let's users > opt-in. But if one expects core.async channels are what most would prefer > anyway, is it okay to foist them upon everyone? > > As a follow up, does your opinion on the matter change if implementations > of an API become simpler using core.async channels? > > > Looking forward to your thoughts :-) > > Chris Small > > > > PS I'm asking because I'm working on a physical computing API ( > https://github.com/clj-bots/pin-ctrl) and debating between using channels > vs callbacks for the edge detection functionality (if you're not familiar, > edge detection let's you asynchronously handle changes in pin state, such > as button pushes). If you're interested in this question as it applies > specifically to this application, feel free to join the discussion on our > gitter channel: https://gitter.im/clj-bots/chat > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.