Fork me on GitHub
#reagent
<
2020-05-04
>
victorb11:05:12

Anyone got any good patterns for making the repetition of the arguments for form-2 components be a bit nicer or remove it completely? Gets a bit unwieldly and error-prone when you start having a bunch of keys and other arguments. Attaching an example My first idea was to write a macro that does it for me, but as always, if there is a nicer way of doing than macros, I'd be happy!

p-himik11:05:54

There's no need to specify all the arguments. Just use what you really use. In your example, it can be as simple as (defn text-input [_] ...).

juhoteperi11:05:48

r/with-let allows using stateful bindings with form-1 components

👍 16
victorb14:05:35

> There's no need to specify all the arguments Yeah, I did that when I started out but always ends up in a situation when I forgot adding something to the second function and then take some time to figure it out...

victorb14:05:06

@U061V0GG2 ah, that's exactly what I'm looking for, thanks a lot!

kenny21:05:40

Woah, I didn't know that existed. That is so useful!! So any form-2 component that just initializes ratoms can be written as a form-1 with r/with-let?

kenny03:05:43

Are there any trade offs with doing so?

Vishal Gautam03:05:01

Not that I know of

victorb07:05:43

yeah, noticed bunch of stuff that is not captured in other places than the changelog (and possibly third party sources), so saving reading through the entire changelog for a rainy day, seems there is more stuff I've (and possibly others) have missed! https://github.com/reagent-project/reagent/blob/master/CHANGELOG.md

victorb07:05:16

yeah, I've been following the changelog (and the news) but missed going back further, like to posts from 2015, thinking it was already written somewhere else. But thanks for linking that one as well!

kenny15:05:16

Wow, I had never seen that. Been using Reagent for many years. This is super cool though. Excited to move many of our components over to it.