Otann / morse

📡 Clojure interface for Telegram Bot API
Eclipse Public License 1.0
257 stars 48 forks source link

Is it possible to pass a core.async channel to the "start" function in polling to get the updates directly into it? #30

Closed dixel closed 6 years ago

dixel commented 6 years ago

.. or maybe have a channel returned directly if no "handler" function is passed. From the perspective of an application relying on core.async and using morse, the most feasible thing to do in the "handler" function is to push the data to another channel in your application which in the current situation is a bit redundant since the "updates" channel in polling is already serving that purpose. From the other hand I can understand that it's the matter of taste what is a better interface for the library - to provide the way to pass a callback handler (which can be more universal since not everybody use core.async in their applications) or a channel. Anyway, I'd be happy to have this ability.

chiliec commented 6 years ago

@Otann what about to add in Readme prefer way to work with updates?

Otann commented 6 years ago

or maybe have a channel returned directly if no "handler" function is passed

that is a very fine addition to the API design, thank you

Otann commented 6 years ago

@Chiliec I suppose it depends on the complexity of the application a lot, whether it should be sync or async, channels or manifolds, polling or not.

But this is something that could I could do for the template for sure.

chiliec commented 6 years ago

@Otann I think most people want to copy-paste code and use polling for rapidly start new bot, but suspension taking requests after some normal working time — totally impermissible 😕

Otann commented 6 years ago

@dixel how about if a handler is a channel, you get updates there? this sounds like a decent interface and easily doable: f0708f0

dixel commented 6 years ago

@Otann yes, this interface is actually perfect for some of the scenarios that I have, I suppose this can be closed then when you're ready to give it a go.

Otann commented 6 years ago

released as 0.4.0