Fork me on GitHub
#reagent
<
2016-04-11
>
mccraigmccraig08:04:45

@nooga have a look at reactions

mccraigmccraig08:04:38

or re-frame subscriptions (which are built on reactions

nooga08:04:03

I’m struggling to find the docs for them

martinklepsch08:04:04

@sivakumargsk: taking this here as #C03RZGPG1 is for announcements only simple_smile

martinklepsch08:04:23

@sivakumargsk: is your atom a reagent.core/atom?

sivakumargsk08:04:55

Hey, I got a problem with a checkbox in reagent-forms. For old version it works fine [reagent-forms "0.5.21"] but for new version [reagent-forms "0.5.22"] it doesn't work well. The problem is the checkbox is not turned into unchecked when I click on the checkbox. But my atom is changed. This is my code (defn home-page [] (let [doc (atom {:name true})] (fn [] [:div [:p (str @doc)] [bind-fields [:input {:field :checkbox :id :name}] doc] [:button.btn.btn-default {:on-click #(reset! doc nil)} "clear"]])))

mccraigmccraig08:04:38

@nooga: have a look at re-frame's docs - re-frame subscriptions are just a registration layer over reagent reactions - https://github.com/Day8/re-frame#subscribe

martinklepsch08:04:49

@sivakumargsk: see my question above

grav09:04:49

hey, there was an example posted, where a color scale was generated with reagent. does anyone have a link?

sivakumargsk09:04:19

@martinklepsch: my atom is reagent.core/atom

nooga09:04:22

I need to experiment with reactions then

mikethompson09:04:23

@grav: you can always google. These channels are archived here: http://clojurians-log.mantike.pro/

leonfs13:04:01

Hi.. I’ve been wondering what the following effectively does..

leonfs13:04:02

(defn lister [items] [:ul (for [item items] ^{:key item} [:li "Item " item])])

leonfs13:04:17

—> ^{:key

leonfs13:04:42

In reagent main website there is a note explaining the reason..

leonfs13:04:08

my question is more in terms of Clojure/ClojureScript syntax

leonfs13:04:38

wouldn’t be the same to actually do :

cky13:04:01

Yep, you could do that too. But there are cases where metadata is more reliable than setting key property.

cky13:04:51

For example, if you're using a component whose first parameter is not a map, the key in map approach won't work.

cky13:04:17

and using metadata is your only option.

leonfs14:04:34

Cool.. thks @cky

leonfs14:04:52

I will read the metadata bit, hopefully it will make more sense after it..

cky14:04:34

The key takeaway is: metadata always works, and the key-in-property-map approach only works if it’s in the first argument to your component, which won’t work if your component doesn’t take a property map as its first parameter.

cky14:04:03

#lessonlearnedthehardway

cky14:04:03

Oh, your Slack profile says you’re in British time. Well, then, #lessonlearntthehardway. 😉

cky14:04:34

@leonfs: ^

leonfs14:04:40

do you have an example of a component that wouldn’t take a property map as it’s first parameter?

cky14:04:08

@leonfs: Not sure about standard components, but I’ve written such components myself.

cky14:04:00

I wouldn’t do that any more, but since Reagent doesn’t require your components to take a property map as the first argument (or as any argument), it is possible for other components to make similar design choices.

rafd15:04:41

@leonfs: if you follow the re-frame pattern, many top-level / singleton components don't take any arguments b/c they subscribe to data they need instead; ie. any component that would take in the entire app-state wouldn't need any arguments when using the re-frame pattern