This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-10
Channels
- # announcements (16)
- # aws (1)
- # babashka (2)
- # beginners (33)
- # biff (2)
- # clj-kondo (13)
- # cljs-dev (1)
- # cljsrn (3)
- # clojars (6)
- # clojure (198)
- # clojure-australia (3)
- # clojure-europe (41)
- # clojure-france (3)
- # clojure-nl (2)
- # clojure-spec (7)
- # clojure-uk (12)
- # clojurescript (57)
- # clojureverse-ops (1)
- # code-reviews (3)
- # community-development (2)
- # conjure (10)
- # data-science (1)
- # datomic (15)
- # depstar (2)
- # docker (2)
- # etaoin (1)
- # events (1)
- # exercism (5)
- # fulcro (23)
- # helix (23)
- # introduce-yourself (4)
- # jobs (6)
- # kaocha (1)
- # lsp (11)
- # meander (107)
- # off-topic (8)
- # pathom (3)
- # polylith (33)
- # re-frame (23)
- # reagent (7)
- # reitit (28)
- # remote-jobs (3)
- # sci (1)
- # shadow-cljs (2)
- # specter (5)
- # sql (38)
- # tools-deps (72)
- # web-security (9)
- # xtdb (32)
@benjamin.schwerdtner mostly core.async
is a "glue" technology so you find it in apps, rather than libraries.
Curious about this. Was planning on using core.async for some socket stuff-- would you recommend something like manifold for building a lib around sockets? Thanks in advance!
@UN8GKGSBG Depending on what you are trying to do, I'd use core.async
. We use core.async
at work for a web socket app.
Basically wanting to wrap a socket talking to postgres in a functional (clj / cljs) library and as byte buffers move up in abtraction (e.g. buffer -> frontend/backend messages -> query/commands), to pass that data via channels. But I just want to make sure that's an okay approach for a library
Possibly. It's hard to design a library that uses core.async
"correctly". It's hard to design any async library.
Most core.async libraries you can find are usually enhancements/additions to the core.async library rather than building something completely new on top of it. CSP is a pretty powerful paradigm, you can express a ton of things with it, esp. when you combine it with transducers. One of my favorite libraries to use together with core.async is https://github.com/cgrand/xforms
For example, you can easily compute a running average of number values as they flow through a core.async channel.
Are you asking in the general case, what is the difference between put! and >! or asking about those literal snippets?
The use case is to put something on a channel from synchronous code, if that makes sense
put! ignores the "meeting" part and just throws a value on the channel without regard for of anyone wants it
If you use put! with the call back, the callback won't be called until the put! value is consumed (more or less, if it is a buffered channel and there is space in the buffer too)
So you can "meet" via the callback, do something; use put! with cb; do it again in the cb
Whats the best way to get a value out of a map when I don't know the key? Trying to access value of a iteration over a list of indexed entities (e.g. {23 {:id 23 :name "Steve"}}) and trying to write some predicates that will work regardless of the id
Are you thinking of something like this?
(let [m {1 :a 2 :b 3 :c 4 :d}]
;; extract keys that are even
(reduce-kv (fn [acc k v]
(if (even? k)
(assoc acc k v)
acc))
{} m))
You want to extract out a submap, or only the values associated to keys satisfying some predicate?
I want to write (defmulti foo identity)
but I’m somewhat hesitant. My questions are: Why not let the user define what they want to dispatch on? Am I misusing mulitmethods this way? Is this method underspecced in the sense that it is likely hard to identify how dispatching works when enough multimethods are added? Edit: it doesn’t work like I was thinking does it?
the user is accessing the source code ?