This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-12
Channels
- # aleph (22)
- # aws (7)
- # babashka (17)
- # beginners (69)
- # chlorine-clover (9)
- # cider (2)
- # clj-kondo (3)
- # cljdoc (30)
- # clojure (113)
- # clojure-dev (30)
- # clojure-europe (11)
- # clojure-italy (2)
- # clojure-nl (16)
- # clojure-spec (1)
- # clojure-sweden (3)
- # clojure-uk (17)
- # clojurescript (77)
- # cryogen (12)
- # data-science (5)
- # datomic (27)
- # duct (2)
- # emacs (37)
- # fulcro (24)
- # graphql (2)
- # kaocha (1)
- # lambdaisland (27)
- # leiningen (4)
- # off-topic (15)
- # onyx (1)
- # other-lisps (3)
- # re-frame (94)
- # reagent (2)
- # reitit (20)
- # ring (1)
- # shadow-cljs (66)
- # spacemacs (5)
- # sql (59)
- # tools-deps (140)
- # vim (1)
- # xtdb (17)
I'm trying to create a stream from an existing stream xs
in a way that put!
s are automatically encoded to JSON and takes!
decoded from JSON βΒ it doesn't seem possible with the current API; should I just create two separate streams, one that is sink-only and another that is source-only?
the question is about Manifold not Aleph, but I thought this would be the right place to ask nevertheless
i don't know that you can do that @eallik - there's just the single xform
on the stream
constructor
but why do you want to do that ? why not just put the object directly on the stream ?
I thought I'd just remove the hassle of json->
and ->json
every time I take!
from or put!
to a connection
(stream/transform (map json->) s)
(stream/transform (map ->json) s)
will those not do the trick ?
yes, use sink-only
and source-only
where it makes sense
ah, ok - in which case does a plain (stream/map ->json s)
do the trick for you ? iirc stream/map
is very simply implemented with connect-via
(defn convert-stream [f-src f-dst s]
(let [src (s/map f-src s)
sink (s/stream)]
(s/connect-via sink #(s/put! s (f-dst %)) s)
(s/splice sink src)))
looks like it will work
(without me doing any testing, anyway π¬)
it worked when I changed to (s/connect-via sink #(s/put! s (f-src %)) s)
β I got confused by the fact that messages should be delivered from the sink to the source, because on the outside, they are written to the sink and read from the source
in fact, the names f-src
and f-dst
are confusion β they should instead be f-sink
and f-source
to indicate which one gets applied to which end of s