This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-25
Channels
- # adventofcode (3)
- # aleph (24)
- # architecture (8)
- # beginners (53)
- # boot (34)
- # cider (7)
- # clara (68)
- # cljs-dev (6)
- # cljsrn (3)
- # clojars (10)
- # clojure (71)
- # clojure-germany (2)
- # clojure-italy (10)
- # clojure-nl (25)
- # clojure-serbia (4)
- # clojure-spec (13)
- # clojure-uk (48)
- # clojurescript (31)
- # core-async (62)
- # cursive (13)
- # datomic (4)
- # duct (76)
- # editors (4)
- # fulcro (2)
- # immutant (1)
- # instaparse (1)
- # jobs (1)
- # lein-figwheel (1)
- # mount (1)
- # off-topic (12)
- # onyx (8)
- # re-frame (10)
- # reagent (84)
- # reitit (2)
- # ring (2)
- # shadow-cljs (159)
- # spacemacs (2)
- # specter (17)
- # sql (14)
- # tools-deps (10)
- # yada (15)
put! is async, but with alt! or alt!! etc. you can have a timeout for >! or >!!
an error happens, but it's async
by not using put!
>!
and >!!
both impose backpressure
parking or blocking
if the number of >! increases, we're going to end up with lots of parked put operations
and for each parked >!, you know the next line of code isn't running
as long as you aren't doing something stupid like firing up a new thread for every input, that's backpressure
👋 Hi everyone! I'm venturing into the land of core.async
+ cljs-ajax
does anyone have any reference guides that can help a newb like me? I'm having a hard time finding something in the Googlies
first question is if you even need or want core.async, I know that cljs-ajax imposes that but that doesn't mean you shouldn't evaluate the question
Hi @noisesmith great to see you again! I've been using js promises and... well... I heard the devx of channels is bettah
+ I want to sharpen my core.async skills (of which now I have 0)
yeah, just making sure it's an intentional choice, since core.async tends to take over and impose some quixotic limitations
well, I have to do a LOT of async stuff on this project I'm working on (talking to and coordinating a number of different APIs), so I was hoping that coordination would be easier with core.async
yes, that is what it's for, so it sounds like a good fit
or should I just pipe promises
in cljs, core.async is going to be a nicer experience. I would check out the core.async intro - in cljs you don't have the blocking operations, but you can put put!
and take!
into callback code, and put normal code into the callbacks that put! and take! accept
as a bonus, I heard I can use all the sequential goodies on channels (transducers, reducers, etc.)
ok, just the intro in http://clojurescript.org?
this is a good basic intro https://github.com/clojure/core.async/blob/master/examples/walkthrough.clj
http://clojurescript.org has a core.async intro?
sorry, I meant http://clojuredocs.org
I'll brush up on the code in the walkthrough
is there anything that combines cljs-ajax
with core.async
?
you really shouldn't need that beyond knowing that take! and put! can be called in a callback, and in turn they take a callback arg each
that's your "glue" that lets you transfer between core.async world and normal world
alrighty... I'm so used to complexion
with javascript libraries, I'm not used to thinks being straight forward like that 😄
there's a lot of complexity to core.async itself, and it can take a while to get used to thinking about the interface between async world and non-async world as part of control flow, but the mechanics are that simple at the bottom of it
When using go
blocks, do I have to do everything inside the go
block like with promises or can I store something from one go block into a def
and using it separately?
you may want to start with a general clojure tutorial before diving in to core.async
def inside a go block is a bad idea
and yeah, make sure you understand clojure / clojurescript
I'll grudgingly allow def inside let sometimes, if let is at the top level
haha, I have dipped my toes in clojure(script) a bit... some http://exercism.io tutorials
sorry, not def
inside a go
, but a go
inside a def
go returns a channel that delivers a value if/when go exits
I've also read most of "Structure and Interpretation of Computer Programs" I've never learned so much from a programming book
ok, so I can pull a value out of a go
and return it from a def
and use it later
that's what I was hoping, to write async code as if it were happening in lexical order
the code inside go is async and also lexically ordered local to that block, yes
the points of asynchrony are the channel ops
thank you guys for putting up with me... let me get my feet wet on the guide you shared... I'll be back!
So, I can't exactly use the walkthrough... it's written for clojure and cljs.core.async
doesn't like the examples 😄
is there a better one for cljs?
it surprises me that docs aren't easier to find... it's like *years* old now, right?
the differences should be pretty simple, why not do the examples in clojure then look at the differences between the cljs and clj core.async versions afterward?
there's just some functions in core.async that make no sense without real threads
Ok, that seems reasonable. I'm just surprised that there are seemingly no docs that chart the differences/gotchas between the two
it's a small list - iirc it's only thread
and things that end in !!
that don't exist in cljs, any other differences have to do with how macros are used in cljs
also this intro is cljs specific http://rigsomelight.com/drafts/clojurescript-core-async-todos.html
thank you @noisesmith patient as always