Fork me on GitHub
#reagent
<
2017-11-21
>
minikomi03:11:40

Thanks, I'll take a look. Still seems like a problem where many people cobble together a just-enough solution and then move on. Enter/exit animations can be pretty painful!

aconanlai15:11:19

does anyone have any links to repos of well-made small-to-medium size reagent apps? i'm looking to read some source code to get a better idea of idiomatic cljs and also project organization

mikerod16:11:45

it is a toy example still, but a bit larger than the “TODO list”

mikerod16:11:11

You may be looking for more real than that - I don’t know of anything better at the moment (I like to see things like that too)

cjsauer17:11:50

If I have a component defined as such:

(defn my-widget
  [{:keys [a b c] :as props}]
  (init-some-stuff! props)
  (fn [{:keys [a b c]}]
    [:h1 (str a b c)]))

cjsauer17:11:14

Do I really need to be repeating the function arguments again in the nested function?

cjsauer17:11:48

In other words, what are the consequences of doing this:

(defn my-widget
  [{:keys [a b c] :as props}]
  (init-some-stuff! props)
  (fn []
    [:h1 (str a b c)]))

curlyfry19:11:21

The outer function is only called once, and is meant for setup (as you indicate in your example. The inner function is the renderer, which will re-render when its input changes. Since you don't give the inner function any arguments, the component will render once with the arguments supplied to the outer function, but it will never re-render.

cjsauer20:11:20

Interesting...so then I do indeed have to write out the function arguments twice? Is reagent sort of swallowing the arity exception then? Is that what prevents a re-render?

ajs20:11:22

I don't think arity exceptions exist in JS

cjsauer23:11:33

@U5YHNV0EA oh duh....I'm too used to Java-land. Thank you for your help @U0J30HBRS, much appreciated.

mikethompson20:11:28

@cjsauer there are a bunch of useful tutorials at the bottom of this page, under the heading "Reagent Tutorials". https://github.com/Day8/re-frame/wiki#reagent-tutorials

cjsauer20:11:25

Cool, much appreciated. I'll take a look.

ajs21:11:33

The relationship between function arities that are defined and the arity passed to a component by Reagent is a bit magical and not obvious