Fork me on GitHub
#missionary
<
2022-02-04
>
Aleed14:02:04

Would missionary be a good fit for a reactive streams library (rxjs) replacement for Clojurescript UIs? I’ve yet to fully grok its usage, but its simpler primitives are appealing.

leonoel14:02:55

definitely ! missionary aims to improve over rx, with a better syntax and support for continuous time

👍 1
Aleed14:02:12

the majority of the examples use the m/? so it’ been a bit bumpy trying to follow the guides in cljs

Aleed14:02:41

also curious what to the abbreviations stand for? i tried looking at code docs but couldn’t pick it out sp ap etc

leonoel14:02:03

in cljs, use the task as a function with two callbacks, or pass it to the promise constructor

👍 1
Aleed15:02:35

so does the hello_flow tutorial not apply to cljs? i’ve done the task one, wondering what other ones to do

leonoel15:02:59

it does work in cljs as long as you don't use ? outside of sp/`ap`

👍 1
Aleed16:02:58

so i figured this would return the value (await-promise (promise! (m/reduce + (m/seed (range 10))))) but it seems to be returning another missionary fn to call

leonoel16:02:51

what is await-promise and promise!

Aleed16:02:03

they are copied from the docs

(defn promise! "Runs given task and returns a promise completing with the result of this task" 
  [t]
  (js/Promise. t))

(defn await-promise "Returns a task completing with the result of given promise"
  [p]
  (let [v (m/dfv)]
    (.then p
           #(v (fn [] %))
           #(v (fn [] (throw %))))
    (m/absolve v)))

leonoel16:02:19

await-promise and promise! cancel each other

leonoel16:02:38

(def cancel ((m/reduce + (m/seed (range 10))) (.-log js/console) (.-error js/console)))

👍 1
leonoel16:02:52

use this as your entry point

Aleed16:02:48

cool, i’m starting to get it 🙂 thanks for the assistance