This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-08
Channels
- # announcements (14)
- # babashka (12)
- # beginners (140)
- # calva (2)
- # cider (22)
- # clj-commons (14)
- # clj-kondo (49)
- # cljdoc (34)
- # clojure (92)
- # clojure-europe (41)
- # clojure-france (2)
- # clojure-new-zealand (2)
- # clojure-nl (2)
- # clojure-norway (60)
- # clojure-uk (17)
- # clojured (2)
- # clojurescript (7)
- # community-development (3)
- # conjure (2)
- # cryogen (13)
- # cursive (4)
- # data-oriented-programming (2)
- # datahike (5)
- # datomic (12)
- # defnpodcast (10)
- # events (2)
- # fulcro (20)
- # gratitude (3)
- # honeysql (4)
- # introduce-yourself (3)
- # jobs (10)
- # lsp (58)
- # malli (12)
- # missionary (19)
- # off-topic (8)
- # pathom (18)
- # podcasts-discuss (1)
- # polylith (41)
- # releases (1)
- # remote-jobs (3)
- # shadow-cljs (52)
- # spacemacs (1)
- # sql (37)
- # xtdb (19)
I ran into a breaking change with this piece of code when upgrading from b.20 to b.26
(defn- wait-until
[doc-ref pred]
(->> (m/observe (fn [emit!] (.onSnapshot doc-ref emit!))) ; get flow of updates to document
(m/eduction (comp (map firebase/doc) (drop-while #(not (pred %))) (take 1))) ; get first doc matching predicate
(m/reduce #(reduced %2)) ; return doc
(m/timeout 10000))) ; fail after 10s
The error I’m seeing is TypeError: task.call is not a function
ah, that looks like timeout now takes the task as first arg instead of second?
(which I guess makes sense if you think about tasks as maps and flows as seqs)
Do you have an idea why this would never log :x
(defn- wait-until
[doc-ref pred]
(m/timeout
(->> (m/observe (fn [emit!] (.onSnapshot doc-ref emit!))) ; get flow of updates to document
(m/eduction (comp (map (fn [x] (js/console.log :x x) x))
(take 1)))
(m/reduce #(do (js/console.log :wait-reduced %2) (reduced %2)))) ; return doc
10000)) ; fail after 10s
it does log wait-reduced
nil
I’m not sure I understand, zero arity would mean no arguments? how would that work?
The docstring doesn’t indicate this btw.
Ah, ok I think I’m getting there
it’ll call (reduced nil)
if theres no initial value
A utility to return the first value of a flow and terminate after it could be nice maybe
Also interestingly the code above worked fine with b.20
I don't fully understand why. It may be due to https://github.com/leonoel/missionary/issues/13 however it looks like in clojurescript when a function is called for an undefined arity it's called for a superior arity with nil args instead of raising an exception