Automatically call an API endpoint (selector) when an atom has changed #1543
Replies: 5 comments
-
You should use Atom Effects for that. https://recoiljs.org/docs/guides/atom-effects |
Beta Was this translation helpful? Give feedback.
-
@BenjaBobs Thanks man. It worked. How do I update a different atom inside effects? |
Beta Was this translation helpful? Give feedback.
-
I don't think there's currently a way to set the value of another atom from the first atom's effect. @drarmstr can you comment on this? I think I've seen this come up a lot. |
Beta Was this translation helpful? Give feedback.
-
I started to use the effects as well which are pretty handy. However having the ability to set other atoms inside would be a great addition. |
Beta Was this translation helpful? Give feedback.
-
Updating other atoms from an effect can allow more opportunities for complex cycles and make it easier to introduce bugs so we are hesitant to introduce it so far. Normal React |
Beta Was this translation helpful? Give feedback.
-
Hi, I am implementing auto-save where an API should be called everytime the atom is updated. The API endpoint is inside a selector.
The atom is
Please advice. I see that useRecoilTransaction might be able to solve it, but the documentation says its only for updating atoms for now.
Beta Was this translation helpful? Give feedback.
All reactions