Fork me on GitHub
#missionary
<
2021-12-03
>
ribelo00:12:19

can i somehow cancel the task from outside?

ribelo00:12:25

something like clearTimeout ?

leonoel19:12:55

this is not public, what are you trying to do ?

meta-meta05:12:14

https://clojurians.slack.com/archives/CL85MBPEF/p1637224678064700?thread_ts=1637100540.046800&amp;cid=CL85MBPEF Hi @leonoel and everyone else! I'm a React dev for 6 or 7 years and I develop VR music software in my free time. I'm looking to implement something like this: https://youtu.be/dWbm9AzgDxw?t=101 I'm working with Arcadia which is a clojure-clr integration for the Unity game engine. I need something that manages DAG data-flow like a spreadsheet and some way to observe updates to each cell so I can reflect changes in the UI. Each cell would be represented by some interactive game object. The example you posted about signals in a reactor makes sense except instead of rendering DOM, I'd be creating cells (adding signals?) on the fly and I'd want to update just that cell's corresponding game object when its value changes. Is there some way to subscribe to changes in an individual signal?

meta-meta07:12:57

Thinking about this some more, the single subscription to the whole graph would work. Each cell's game object can just look at its value in the latest state and update itself if the value has changed. I don't need to think of the change as an event like I was inclined to because game objects have an update hook running at 60fps.

meta-meta07:12:49

What I'm missing now is, how do you add/remove signals within a reactor dynamically?

leonoel21:12:59

To add a signal, just call signal!. It can be done dynamically but it must be in reaction to an event processed by the reactor. To remove a signal, you can call it as a function with no argument, it will cancel the underlying process

👍 1
leonoel21:12:37

That's an interesting use case, is CLR support required here ?

meta-meta23:12:40

I was initially thinking CLR is required but after some thought, it wouldn't add much complexity to run Missionary on a CLJ server and send update messages to the VR client. In my case it might even be preferable since all the code I'm trying to wrap is already in a CLJ project with OSC and MIDI communication setup.

Dustin Getz14:12:20

Hi Paul. signals can contain signals (i.e. higher order), and there is an operator to flatten nested signals, you can use m/latest to get a value out of a signal that happens to be a signal and then use it accordingly

🙏 1
ribelo10:12:34

why this work

(defn somefn [[x d]]
  (println :x x :d d)
  (mi/sleep d x))

((mi/reduce conj (mi/ap (mi/? (somefn (mi/?> (mi/seed [[:a 1000] [:b 1000] [:c 1000]])))))) (constantly nil) prn)
but this not?
(defn someotherfn [[x d]]
  (println :x x :d d)
  (mi/? (mi/sleep d x)))

((mi/reduce conj (mi/ap (someotherfn (mi/?> (mi/seed [[:a 1000] [:b 1000] [:c 1000]]))))) (constantly nil) prn)

Ben Sless11:12:50

Probably ap changes the semantics of ?

ribelo11:12:19

but for example in core.async the use of go also allows you to use <! inside called functions etc.

ribelo11:12:58

and I have no idea how to get around it

Ben Sless11:12:57

not so, you have to use <! inside a go block. Which means you need to return the equivalent of a go block from the function, i.e. return a ap from it

ribelo12:12:29

indeed, as you can see I'm remembering wrong 😜

😅 2
leonoel19:12:43

? is undefined outside of sp and ap for the same reasons <! and >! are undefined outside of go

leonoel19:12:14

? is a delimiter for syntax rewriting, which is a compile-time transformation

leonoel19:12:26

in the general case, we can't rewrite syntax if we assume parking can happen in arbitrarily nested frames