This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-28
Channels
- # aws (5)
- # aws-lambda (1)
- # beginners (133)
- # boot (1)
- # cljsrn (1)
- # clojure (28)
- # clojure-austin (3)
- # clojure-italy (2)
- # clojure-spec (17)
- # clojure-uk (18)
- # clojurescript (38)
- # cursive (6)
- # datomic (6)
- # figwheel (1)
- # graphql (1)
- # klipse (1)
- # leiningen (1)
- # off-topic (13)
- # onyx (30)
- # re-frame (44)
- # reagent (7)
- # shadow-cljs (77)
- # spacemacs (7)
get rid of your redundant render-func
? 😄
@reefersleep: can you directly render an atom ?
I’m guessing not, but I’d test it for sure
rc/render
needs some kind of hiccup structure to display anything, I bet
I don’t understand how your two questions are related
Can you deliberate on your logic? 🙂
If I wanted to display my state atom, I’d just wrap it in a [:div]
or [:pre]
Oh, sorry about that. I was kidding, actually. I see that you mean to refer to your let-binding in rc/render
, but you managed to write two different symbol names 😉
render-func
and render-state
I see, they should both be render-func .... that was a typo on my part (half refactoring)
Maybe just: (rc/render [:pre @gui-state] app-div)
?
not sure if you can use literal hiccup directly in rc/render
think I actually saw some issue related to it a while ago
hm, good point
Your code is pretty minimal already 🙂 Does it work without wrapping the dereffed state, though? I guess it’s indirectly wrapped in your app-div
element
Without wrapping it in some dom element, I mean.
2. the original problem was this: was streaming state from websocket from server to client
interesting!
and this 'atom' was just a layer of indirection to store the state; either way, I'm okay with keeping the render-func around
Yeah, that doesn’t seem superfluous to me
you’ve even scoped it as minimally as possible
yeah, I find the clj repl much nicer to work with than the cljs repl, so this way, I can write client side code in *.cljc, run the updates in clj/jvm, and have it send the hiccup to cljs, which just does a dumb render
So it’s purely for development support?
Alright. Nice tool!
Maybe it makes sense to opensource it?
If others agree with your proclivities
Gotcha.
Did you get it working again?
brilliant :thumbsup:
I'm reading https://stackoverflow.com/questions/32367273/touch-left-touch-right-events-in-reagent -- and wondering -- is there sample reagent + touch event code somewhere ?
Not when I searched for it about a year ago, I ended up using hammer, https://clojars.org/cljsjs/hammer, and add it to a reagent component in the on-mount like:
(let [mc (new js/Hammer.Manager (r/dom-node this))] (js-invoke mc “add” (new js/Hammer.Pan #js{“direction” js/Hammer.DIRECTION_ALL “threshold” 0})) (js-invoke mc “on” “pan” #(let [direction (.-direction %)] (cond (= direction 😎 (dispatch [:change-direction [0 -1]]) (= direction 16) (dispatch [:change-direction [0 1]]) (= direction 4) (dispatch [:change-direction [1 0]]) (= direction 2) (dispatch [:change-direction [-1 0]]) ))) (reset! hammer-manager mc))