Atom effect able to get another atom's value
See original GitHub issueI’ve been looking into atom effects and they look really helpful. In the example, it shows a state synchronization example effect like this:
const syncStorageEffect = userID => ({setSelf, trigger}) => {
// Subscribe to remote storage changes and update the atom value
myRemoteStorage.onChange(userID, userInfo => {
setSelf(userInfo); // Call asynchronously to change value
});
// Cleanup remote storage subscription
return () => {
myRemoteStorage.onChange(userID, null);
};
};
That looks perfect, if myRemoteStorage
is a static, but how would you structure that same effect when myRemoteStorage
is coming from a Recoil value? If the datastore is also tracked in a Recoil atom, then I can’t figure out a good pattern for using it in an effect. Was there an approach in mind to handle that pattern?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:18
- Comments:20 (5 by maintainers)
Top Results From Across the Web
Atom Effects | Recoil
Atom effects are an API for managing side-effects and synchronizing or initializing Recoil atoms. They have a variety of useful applications such as...
Read more >Can I change other pieces of state in a Recoil Atom Effect
I have several Atoms: An atom which stores an authentication token, for use when communicating with the storage API. Atoms for various pieces...
Read more >Electron Affinity - Chemistry LibreTexts
As the name suggests, electron affinity is the ability of an atom to accept an electron.
Read more >Mastering Periodic Trends
pairs orient themselves as far away as possible from each other, causing the electron cloud to expand (justifies trends across a period). 1....
Read more >Electronegativity - Definition, Periodic Trends, Effect ... - Byju's
Factors Affecting Electronegativity · 1. Size of an Atom: A greater atomic size will result in less value of electronegativity, this happens because...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mdlavin - We are exploring the ability for atom effects to look at the state of other atoms, perhaps via providing a mechanism like
getSnapshot()
as a callback for the atom effect.also i think it’s a good feature if it possible that in effects_UNSTABLE.onset, update other atom. i want some atom’s effect propagation to other atom’s effect.