This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-08
Channels
- # admin-announcements (3)
- # arachne (1)
- # aws (2)
- # beginners (10)
- # boot (287)
- # cider (5)
- # clara (2)
- # cljs-dev (150)
- # cljsjs (2)
- # clojure (99)
- # clojure-austin (1)
- # clojure-brasil (1)
- # clojure-dev (13)
- # clojure-greece (55)
- # clojure-japan (1)
- # clojure-nl (2)
- # clojure-russia (24)
- # clojure-spec (184)
- # clojure-taiwan (1)
- # clojure-uk (45)
- # clojurescript (55)
- # clojurex (1)
- # cursive (20)
- # datascript (16)
- # datomic (1)
- # devcards (4)
- # events (10)
- # figwheel (1)
- # funcool (7)
- # hoplon (48)
- # immutant (1)
- # jobs (6)
- # lambdaisland (2)
- # lein-figwheel (19)
- # mount (36)
- # off-topic (37)
- # om (16)
- # om-next (17)
- # onyx (29)
- # planck (53)
- # proton (1)
- # pure-frame (1)
- # re-frame (40)
- # reagent (44)
- # remote-jobs (1)
- # ring (2)
- # robots (2)
- # rum (5)
- # slack-help (4)
- # spacemacs (27)
- # specter (82)
- # test-check (18)
- # test200 (1)
- # untangled (17)
guys, hello
having a problem here creating a custom component using props and children in arguments
something like this (but is not working)
(defn tab
[& props children]
[rui/tab (merge props {:style {:padding-top tab-padding-top}})
(map-keys children)])
errors ... i think i have the arguments wrong but can't find out what exactly
@michael.heuberger: what escherize said. &
in the argument list "Bind the rest of the arguments to this name", so your function can take any number of arguments. If a function has an argument list of [a & b]
and I call it with (my-fun 1 2 3 4 5)
, a
would be 1
and b
would be [2 3 4 5]
.
I'm trying to figure out where to put my state in Reagent components, compared to how I'd normally approach it in React
in React I'd stick to props as much as possible and use callbacks to update state in a parent component, but it seems like the "Reagent way" is to pass atoms to children for them to deref and modify themselves
I have an app where you select configuration profiles in the sidebar and edit that profile in the main container
there is a single main component, with child components for the profile selector and configuration editor
if it were just React, I'd use callback functions as props to handle things like changing the selected profile
but from the Reagent examples it seems like I might want to pass an atom representing the selected profile to the profile selector itself and let it update that atom
but that seems a little messy
but it also seems simpler
am I on the right track?
@jcromartie I’d recommend you to check http://keechma.com and https://github.com/Day8/re-frame to see examples of architectures in reagent. But the main idea is that you send data down, commands up and change the main atom somehow which will propagate down to the UI.
if you have any questions about keechma, I’m the lead dev so feel free to ask me
so, in that case, would the "main" component be the only thing dereferencing the "main" atom?
I'm checking the Keechma examples now
there is a concept of “subscriptions” which allow you to dereference parts of main the main atom
so each component gets only the data it needs
reagent will take care of updating the component when the data in the subscription changes
here are subscriptions for the todomvc example (notice that they are wrapped inside the reaction
macro) https://github.com/keechma/keechma-todomvc/blob/master/src/keechma_todomvc/subscriptions.cljs
nice project BTW
thanks 🙂
the logo makes me want to listen to synthwave
or fire up my Amiga
For now I'm trying to really grok the basics of Reagent. I'd love to check out Keechma more but I want to avoid adding more libs if I can. I think my app is really simple.
@jcromartie: you can do basic subscription stuff yourself with the reaction
macro https://github.com/reagent-project/reagent/blob/master/src/reagent/ratom.clj#L5 in a vanilla form-2 component... have a read of the keechma todomvc code above to figure out how reaction
can work and take a look here for a good overview of the different ways of creating react components with reagent https://github.com/Day8/re-frame/wiki/Creating-Reagent-Components
do I really need subscriptions?
basically I have a thing on the left to select what to edit on the right, that seems quite simple
the examples here are helpful, but I am getting the sense that they are definitely not best practices http://reagent-project.github.io/
you don’t need subscriptions, but after the app grows it makes sense to split it into reading and writing parts. it helps with the code scalability. but even if you start without subscriptions it won’t be too hard to migrate later