This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-19
Channels
Hello, I want to change an atom only when another atom changes value, ho wdo I do that? For example, I have a value
(let [button-disabled? (r/atom true)])
I also have children that are
(let [email-button-disabled? (r/atom true)
number-button-disabled? (r/atom true)])
When one of them turns false, I want to change the main one.it looks like those are not normal Clojure atoms but atoms from reagent library. if that is the case then look at reactions provided by reagent https://github.com/reagent-project/reagent/blob/master/doc/ManagingState.md#reactions
also there is #C0620C0C8 channel
Add-watch will work too I believe! But reactions are nice of course
Hello y’all, thanks for the amazing help last time! I’ve been banging my head against a sort problem regarding a vector of maps and maybe someone is able to point me into the right direction. I have following structure:
[{:score 22/111, :size 2}
{:score 8/113, :size 3}
{:score 200/221, :size 19}
{:score 8/113, :size 6}
{:score 2/3, :size 20}
{:score 1N, :size 3}
{:score 0, :size 2}]
I now want to sort this by score descending
and by size ascending
like this:
[{:score 1N, :size 3}
{:score 200/221, :size 19}
{:score 2/3, :size 20}
{:score 22/111, :size 2}
{:score 8/113, :size 3}
{:score 8/113, :size 6}
{:score 0, :size 2}]
I already tried to wrap my head around the sort-by
, group-by
and min/max-key
functions, but I wasn’t able to find the correct way to combine these for the desired result.
I’m grateful for any help and/or push in the right direction 🙂(->> data
(sort-by (juxt #(- (:score %)) :size)))