Fork me on GitHub
#missionary
<
2022-02-05
>
ribelo21:02:18

(def !input (atom 1))
  (def main (mi/reactor
             (let [>x (mi/signal! (mi/watch !input))       ; continuous signal reflecting atom state
                   >y (mi/signal! (mi/latest + >x >x))]    ; derived computation, diamond shape
               (mi/stream! (mi/ap (println (mi/?< >y))))))) ; discrete effect performed on successive values

  (def dispose! (main #(prn ::success %) #(prn ::crash %)))
                                        ; 2
  (swap! !input inc)
                                        ; 4
  (dispose!)
on cljs dispose! dosen't print anything

Dustin Getz21:02:40

check various consoles, async prints may not be caught and redirected to the nREPL

ribelo22:02:39

yes, I know, but it really doesn't print anywhere

ribelo22:02:03

I also used tap> + shadow-cljs inspect stream

ribelo22:02:09

((mi/sp (mi/? (mi/sleep 1000 :sleep))) prn prn) works without any problems