This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-03
Channels
- # adventofcode (107)
- # announcements (1)
- # asami (14)
- # babashka (67)
- # beginners (89)
- # calva (34)
- # cider (17)
- # clj-kondo (5)
- # cljs-dev (2)
- # clojure (57)
- # clojure-europe (52)
- # clojure-india (1)
- # clojure-italy (1)
- # clojure-losangeles (2)
- # clojure-nl (6)
- # clojure-uk (39)
- # clojurescript (40)
- # community-development (3)
- # conjure (3)
- # cursive (17)
- # datomic (11)
- # docker (13)
- # events (3)
- # figwheel-main (3)
- # fulcro (12)
- # graalvm (7)
- # holy-lambda (7)
- # honeysql (9)
- # introduce-yourself (5)
- # malli (9)
- # minecraft (3)
- # missionary (21)
- # nextjournal (7)
- # off-topic (52)
- # pathom (3)
- # polylith (11)
- # portal (3)
- # re-frame (21)
- # reagent (34)
- # reclojure (7)
- # reitit (1)
- # reveal (11)
- # shadow-cljs (68)
- # tools-build (12)
- # tools-deps (5)
- # vim (4)
- # xtdb (9)
https://clojurians.slack.com/archives/CL85MBPEF/p1637224678064700?thread_ts=1637100540.046800&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?
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.
What I'm missing now is, how do you add/remove signals within a reactor dynamically?
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
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.
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
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)
but for example in core.async
the use of go
also allows you to use <!
inside called functions etc.
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