Fork me on GitHub
#beginners
<
2023-02-19
>
M J11:02:47

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.

M J13:02:18

Thanks! 🙏

delaguardo15:02:45

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

delaguardo15:02:23

also there is #C0620C0C8 channel

Sam Ritchie16:02:15

Add-watch will work too I believe! But reactions are nice of course