This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-07
Channels
- # beginners (71)
- # boot (25)
- # cider (204)
- # clara (18)
- # cljs-dev (10)
- # cljsrn (64)
- # clojure (50)
- # clojure-dev (2)
- # clojure-dusseldorf (1)
- # clojure-india (5)
- # clojure-italy (1)
- # clojure-nl (21)
- # clojure-poland (65)
- # clojure-spec (41)
- # clojure-uk (10)
- # clojurescript (4)
- # core-async (5)
- # cursive (2)
- # datomic (17)
- # duct (8)
- # emacs (8)
- # fulcro (1)
- # graphql (21)
- # hoplon (2)
- # javascript (3)
- # lumo (25)
- # mount (5)
- # off-topic (5)
- # onyx (3)
- # portkey (6)
- # re-frame (15)
- # reagent (5)
- # rum (1)
- # shadow-cljs (198)
- # spacemacs (19)
- # specter (2)
@twashing here's pub and sub doing exactly what you want
Clojure 1.9.0
:user=> (require '[clojure.core.async :as >])
nil
:user=> (def c (>/chan))
#'user/c
:user=> (def p (>/pub c :id))
#'user/p
:user=> (def c' (>/chan))
#'user/c'
:user=> (def s (>/sub p 1 c'))
#'user/s
:user=> (def c'' (>/chan))
#'user/c''
:user=> (def s' (>/sub p 2 c''))
#'user/s'
:user=> (>/take! c'' #(println % 'has 'id 2))
nil
:user=> (>/take! c' #(println % 'has 'id 1))
nil
:user=> (>/put! c {:id 1 :foo 2})
true
user=> {:id 1, :foo 2} has id 1
@noisesmith Thanks for putting this together. But the line(s) where we subscribe with a specific id… (>/sub p 1 c')