Hi,

I'm no core.async expert but I wrote some core-async-heavy code in the 
past[1].

Async code is contagious. It is better to extract all code which does not 
need to be async into separate functions and introduce async at the edges 
of the system. To keep track of my async/non-async code split I adopted 
pretty useful naming convention. All (async) functions returning channels 
as a promise (typically using go block internally) should have `go-` 
prefix. This way it is clear at all call sites that a channel yielding a 
result is expected. And also this promotes writing functions which are 
"purely async" - they must always return a channel from all possible 
branches, as the `go-` prefix suggests.

I went as far as writing my own macros to wrap subset of core.async to use 
this naming convention[2].

just my $.02
Antonin

[1] 
https://github.com/binaryage/dirac/tree/master/src/background/dirac/background
[2] 
https://github.com/binaryage/dirac/blob/master/src/shared/dirac/shared/async.clj


On Tuesday, November 13, 2018 at 4:10:48 PM UTC+1, Kashyap CK wrote:
>
> [Apologies for cross-posting - but I realize that Clojurescript group may 
> be a better place for this query than the Clojure group :) ]
>
> Hi all,
>
>
> I am attempting to use core.async to poll a service - 
> https://gist.github.com/ckkashyap/c8423dcfc3a3f28b67e18ae76cc13f53
>
> Broadly, I need to hit the service endpoint with a secret to get a token 
> and subsequently use the token to poll for messages.
>
>
> I'd appreciate any feedback on the approach - particularly around
>
> 1. Error handling
>
> 2. Use of channels
>
>
> Is there some project out there I could take a look at to learn the 
> right/good way to do this?
>
>
> Regards,
>
> Kashyap
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at https://groups.google.com/group/clojurescript.

Reply via email to