This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-30
Channels
- # announcements (40)
- # babashka (41)
- # beginners (32)
- # calva (15)
- # clara (8)
- # clj-kondo (14)
- # cljs-dev (30)
- # clojure (37)
- # clojure-dev (8)
- # clojure-europe (21)
- # clojure-norway (21)
- # clojure-uk (4)
- # clojured (3)
- # clojurescript (4)
- # community-development (10)
- # core-async (13)
- # cursive (23)
- # datomic (15)
- # emacs (9)
- # fulcro (3)
- # google-cloud (4)
- # graphql (24)
- # gratitude (2)
- # holy-lambda (4)
- # honeysql (5)
- # hyperfiddle (9)
- # keechma (1)
- # klipse (5)
- # lsp (23)
- # malli (4)
- # missionary (32)
- # pathom (28)
- # re-frame (2)
- # reagent (40)
- # reitit (17)
- # releases (2)
- # remote-jobs (1)
- # shadow-cljs (25)
- # specter (3)
- # vim (19)
- # xtdb (41)
This is an example https://github.com/leonoel/missionary/wiki/Basic-Walkthrough:-Tasks-&-Flows#flow and it's giving me an error:
main.js:1426 Error: Unsupported operation.
at Object.eval [as missionary$impl$Fiber$Fiber$park$arity$2] (Fiber.cljs:12:22)
at Object.missionary$core$park [as park] (core.cljc:162:16)
at Object.missionary_help$core$start_BANG_ [as start_BANG_] (core.cljs:11:3)
at eval (shadow.module.main.append.js:4:28)
at eval (<anonymous>)
at goog.globalEval (main.js:472:11)
at env.evalLoad (main.js:1534:12)
at main.js:1700:12
https://github.com/rgkirch/missionary-help/blob/20744daa4a513f275358f8281d6a9675db4a2b96/src/missionary_help/core.cljs#L15
Error is only in ClojureScript. It works in Clojure.Ok, yea. This works:
((m/reduce
(constantly nil)
(m/eduction (map println)
(m/seed (range 20))))
prn prn)
I thought I could run flows by calling it like a function (flow prn prn)
. I don't know where I got that idea but I guess that's wrong. I can run a reactor by calling it like that and it'll run any flows that I've "marked" as a publisher with signal!
or stream!
but if I'm outside of a reactor then I need to use reduce constantly nil
to get a task and then I run that by calling it.
you can run flows like that
This is the code that I'm trying to understand. I expected to get the same results from both.
yeah, i believe this is backpressure
If you want to understand better how flows work under the hood, you may want to read the specification first https://github.com/leonoel/flow
fixed typos = -> :=
Having a flow, can I somehow emit a delayed value for each value that comes through the flow? Specifically thinking of something like “things come in and need to be removed from state again after a while”
(defn duplicate-delayed [d >x]
(m/ap
(let [x (m/?= >x)]
(m/amb> x (m/? (m/sleep d x))))))
Can you show me how that would work in context with something like observe
? And does this apply to CLJS, does ap
work just the same?
Generally is there any sort of mnemonic around things like ap
?=
?
etc? Everytime I see these functions I’m immediately a bit lost.
Yesterday I was wishing for a more verbose API that reads a bit more like English 😅
So I guess >x
is an idiom for a flow 🙂
Another question 😁 After a reduce
how can I call a callback for each reduced value? thinking of something like this:
(->> (m/observe ,,)
(m/reduce ,,,)
(m/eduction (map callback)))
it is OK to perform side-effects in the reducing function of reduce
, also check reductions
it you need to emit intermediate states
Ah — with reductions
+ side effect in eduction
I think I can get what I want
and yeah side effect in reduce also came to mind but felt a bit less idiomatic/right somehow
Ah, actually maybe more reductions
+ reduce
so the flow is actually consumed?