This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-10
Channels
- # aleph (1)
- # announcements (21)
- # babashka (3)
- # beginners (98)
- # calva (2)
- # circleci (3)
- # clara (58)
- # clj-kondo (123)
- # cljs-dev (1)
- # cljsrn (7)
- # clojure (162)
- # clojure-europe (2)
- # clojure-finland (7)
- # clojure-italy (5)
- # clojure-nl (6)
- # clojure-sanfrancisco (1)
- # clojure-spec (1)
- # clojure-survey (17)
- # clojure-uk (70)
- # clojuredesign-podcast (2)
- # clojurescript (46)
- # cloverage (5)
- # cursive (2)
- # data-science (22)
- # datascript (1)
- # datomic (60)
- # emacs (3)
- # figwheel-main (1)
- # fulcro (26)
- # graalvm (5)
- # jackdaw (3)
- # leiningen (8)
- # luminus (1)
- # off-topic (8)
- # other-lisps (2)
- # pedestal (27)
- # re-frame (17)
- # reagent (20)
- # reitit (3)
- # shadow-cljs (37)
- # spacemacs (23)
- # sql (69)
- # tools-deps (2)
- # utah-clojurians (9)
- # xtdb (3)
Hello! I've got a question about the legitimacy of using add-watch
on the reaction returned by r/track!
(the eager version of track). Details in a post so it doesn't get too long in here:
I think you should be able to use reagent.ratom/run!
to achieve the same while not requiring anything to be IWatchable
.
Hi there, i'm fairly new to reagent and trying to write a component that saves the state of which card got clicked at last (and display it differently than). My approach is the following:
(defn cards []
(r/with-let [selected-card (r/atom nil)]
[:div.container>div.columns.is-multiline.is-centered
(doall
(for [item @(rf/subscribe [:sequence])]
[:div.column.is-narrow>div.playing-card
{:on-click #(reset! selected-card item)
:class (when (= item @selected-card :is-active))
:key item}
[:h1.has-text-centered.has-text-weight-bold.is-size-1 item]]))]))
but this doesn't work and i can't figure out why.
I logged this expression (when (= item @selected-card :is-active))
and it evaluates to true. Without the condition :is-active
also works.
Any help is greatly appreciated.You have :is-active
inside the condition. The body of when
ends up being empty, which evaluates to nil
.
please put the re-frame subscription inside the with-let
bindings and not in the body of the render function. that way the subscription will only be made once. doing it your way will afaik cause a memory leak and at least causes unnecessary computation.
has this changed? when I learned re-frame, the guide was to always create the subscription outside the render function, then just deref it in the render function?
0.9.0 (2016.12.15) • #218 Make it okay to use `subscribe` in Form-1 components. This is a big deal.
@UP2FUP0TT That can be used as an argument, yes. But in this case, I see this difference as very minor, especially given the subs cache.