This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-21
Channels
- # 100-days-of-code (1)
- # announcements (2)
- # beginners (164)
- # cider (23)
- # cljs-dev (30)
- # cljsjs (11)
- # cljsrn (7)
- # clojure (116)
- # clojure-boston (1)
- # clojure-dev (20)
- # clojure-finland (2)
- # clojure-italy (4)
- # clojure-nl (1)
- # clojure-uk (10)
- # clojurescript (39)
- # core-async (19)
- # cursive (43)
- # data-science (2)
- # datomic (24)
- # emacs (10)
- # figwheel-main (20)
- # fulcro (63)
- # hoplon (7)
- # hyperfiddle (7)
- # instaparse (3)
- # kaocha (1)
- # nrepl (3)
- # off-topic (170)
- # onyx (13)
- # other-languages (3)
- # parinfer (13)
- # re-frame (39)
- # reagent (5)
- # reitit (22)
- # ring-swagger (4)
- # shadow-cljs (284)
- # spacemacs (2)
- # sql (27)
- # testing (28)
- # unrepl (2)
Hm, I realise that the use of devcards is very limited in this case, because re-frame puts all the logic into the dominos 2+3.
@gadfly361 I had a look at the re-frame-template +gadfly. Everything seems to be spread through a lot of files. Why did you choose to separate the code into so many different parts, add glue namespaces and so on?
Hi guys
i'm trying to use piechart from recharts with multiple colors but it don't change color for each segment it only fill with only color
got it
i use Scatther rather than Cell
thanks anyway
@urzds Just how i think about things. I prefer the fractal approach when it comes to directory structure and files. Everything always has a home so you dont have to think about what to name things or where to place them and files will never get too large.
is there a good doc on the query vector to a subscription? is there any thing for parameterizing them? (eg. pulling a specific entry from an array?)
What do you mean "parametrizing them" ? Is destructuring not enough ? The first argument is always the event id, so something like '[ arg1 arg2 arg3]. Actually, destructuring can even nest, so you could even write '[ arg1 [arg2_1 arg2_2]] ... this is just pure Clojure, nothing more 😉 (see https://clojure.org/guides/destructuring)
oh, sorry, that's not what I mean
I get how passing the vector around works, but I haven't seen any example of actually including anything in the vector other than the sub's keyword.
what is it useful for, if anything?
I guess it's related to https://github.com/Day8/re-frame/wiki/Dynamic-Subscriptions .... it is somehow discouraged now... anyway, what if you have a subscription called :find-user-by-name .... the name could be put in this vector.
@UCY0GT0QM there is very light treatment in the README https://github.com/Day8/re-frame/blob/69a3fcd411369fff65404e7d6a924ce1968e2dba/docs/INTRO.md#code-for-domino-5
hm. I take it "more in later tutorials" is... optimistic.
Its going to be a bit like this:
(defn item-view
[item-id]
(let [item (subscribe [:items item-id])]
[:div <use @item in here>]))
Well there's more about subscriptions in later tutorials, yes
The concept is so simple that it can't be that you are struggling with that ... so perhaps it is just good examples of its use that you are after? In which case, perhaps example applications might be useful for you .. https://github.com/Day8/re-frame/blob/69a3fcd411369fff65404e7d6a924ce1968e2dba/docs/External-Resources.md
Or perhaps there is something else that is puzzling you?
Can someone please point me to documentation that describes the difference between these variants of a reagent component?
(defn f []
(let [x (re-frame/subscribe [:x]]
(fn []
...)))
(defn f []
(fn []
(let [x (re-frame/subscribe [:x]]
...)))
Rendering is triggered under different conditions, but I don't recall the specification.I think my mistake was that I actually had (let [x (re-frame/subscribe [:x]) y @x] (fn [] ...))
and hence reagent would not see that x
was being derefed inside the fn
.
@urzds https://github.com/reagent-project/reagent/blob/master/doc/CreatingReagentComponents.md ?
But still: In which situation should I use which variant? Does it make a difference? Not sure where to find the docs on that.
Question is: Why should I put the subscribe
in the form-2 variant's outer let, instead of just using a form-1 and putting the let inside?
there is also this discussion that could be interesting for you https://github.com/Day8/re-frame/issues/218
which eventually points to https://lambdaisland.com/blog/11-02-2017-re-frame-form-1-subscriptions
@urzds Form-2 can be useful when you need to create a stateful renderer (you need the renderer to close over some state)
(defn my-view ;; Form-2
[]
(let [count (reagent/ratom(0)] ;;; capture some state
(fn []
[:div <reset! count in response to a button click or something> ])))
But you do NOT need to use Form-2 when using subscribe
All of which is to say that you rarely need to use Form-2 in re-frame.
@mikethompson Thanks!