This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-26
Channels
- # announcements (7)
- # babashka (6)
- # beginners (41)
- # clara (27)
- # clerk (2)
- # cljs-dev (6)
- # clojure (121)
- # clojure-europe (31)
- # clojure-nl (2)
- # clojure-norway (98)
- # clojure-uk (12)
- # clojuredesign-podcast (7)
- # conjure (5)
- # cursive (22)
- # holy-lambda (22)
- # hoplon (9)
- # hyperfiddle (19)
- # leiningen (9)
- # malli (4)
- # music (1)
- # nbb (6)
- # off-topic (10)
- # podcasts-discuss (1)
- # polylith (4)
- # re-frame (2)
- # reitit (2)
- # releases (1)
- # sci (1)
- # shadow-cljs (59)
- # sql (9)
- # vim (41)
- # xtdb (23)
I'm missing something here but haven't figured it out yet. Trying to capture the mouse position on a component.
(defn mouse-position> [element]
(m/observe
(fn [!]
(let [sample (fn [e]
(! {:x (.-clientX e) :y (.-clientY e)}))]
(.addEventListener element "mousemove" sample )
#(.removeEventListener element "mousemove" sample)))))
(defn mouse-position< [element]
(->> (mouse-position> element)
(e/throttle 16) ; RAF interval
(m/reductions {} {:x 0 :y 0})
(m/relieve (fn [acc evt] {:x (.-x evt) :y (.-y evt)}))
(m/latest identity)))
Called liked this in a component.
(mouse-position< dom/node)
I think m/relieve
is wrong, it should be (m/relieve {})
. The caller needs to join the missionary flow with new
, so the callsite should look like (new (mouse-position< dom/node))
note that we already export mousemove events as a singleton https://github.com/hyperfiddle/electric/blob/cc55772f18bc46373f131e092fc20055c8062b59/src/hyperfiddle/electric.cljc#L206
i believe the one in master is broken
The (new (mouse-position< dom/node))
and (m/relieve {})
did the trick. Though I'm not getting my crosshair rendering anymore. So have to figure out why that it.
also i dont understand why we are throttling, I know i have seen that pattern in the electric repo somewhere but maybe it is an old workaround
It didn't really seem to do the trick so I am not throttling now.
Oh and I got it from @U0ETXRFEW searching this channel
I don’t really understand the role of the throttle either. Just that things didn’t work without it. 😃
And right now I don’t even remember if the latest code for our mouse crosshair has the throttle still in place.
Since people here may be interested; how do you solve the yak-shaving problem? Essentially yak-shaving is working (too much) on the tools to solve the problem. I tend to err too much on this side, but often end up finding powerful technologies to justify the search/work.
I sigh a lot instead of working on tools, think about https://codahale.com//work-is-work/, go get a coke
The economics are different when working in a team vs. working by yourself. I’ve spent time on conveniences that I probably wouldn’t have bothered with if it only would impact me. But since they impact a certain number of other people, the gains increase. When Electric solves incremental compilation, it won’t just cut compilation times by <insert number here>, it will cut compilation times by <insert number here> times <number of Electric users>.
"do things that don't scale"
honestly the motivation to ship is to watch retards get rich on things like remix_web while we barely survive for years. As well as learned humility from multi-year efforts to shave a yak that failed in the end because "built wrong thing" 'idea was wrong" "didn't work in practice" etc.
"Time is the denominator"