You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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