This repository has been archived by the owner on Jan 1, 2025. It is now read-only.
What's the best way to handle these particular cases? #1499
Unanswered
Cpt-Falcon
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So lets say I have a form tied to an atom called recommendationsInput and lets say I only want to submit the form on the submit button being clicked. But lets also say there is a downstream async api selector that gets triggered on submission called RecommendationResultsQuery.
For the recommendations input I have an atom family with two string identifiers being "preliminary" and "submit". Any time a change on the form occurs it sets the atom family preliminary identifier. The selector for RecommendationResultsQuery is flowing/triggering from the submit atom identifier. When clicking the submit button it sets the 'submit' identifier atom to the contents of the 'preliminary' identifier atom. This triggers the down stream selector RecommendationResultsQuery so that it isn't making an API call each time something on the form changes.
Is this a good way of doing things in recoil/is there a better way?
Another thing I've been doing is things like "RecommendationResultsCacheQuery", which is very simple selector and only looks at the atom family submit mentioned above. Then I have another down stream selector "RecommendationResultsQuery" which manipulates that cache selector data in a variety of ways and is dependent on multiple other atoms. This saves on API calls because combining the cache query and regular query into a single selector would mean an API call each time any of the atoms change whereas it really only needs to make an api call when a single atom changes. Is this generally a good idea as well?
Beta Was this translation helpful? Give feedback.
All reactions