Recoil has functionality to allow you to observe and update state changes.
This API is currently under development and will change. Please stay tuned...
Once you have a
Snapshot, you can use methods such as
getInfo_UNSTABLE() to inspect the state and use
getNodes_UNSTABLE() to iterate over the set of known atoms.
useGotoRecoilSnapshot() hook can be used to update the entire Recoil state to match the provided
Snapshot. This example maintains a history of state changes with the ability to go back and restore previous global state.
Snapshot's also provide a
getID() method. That can be used, for example, to help determine if you are reverting to a previous known state to avoid updating your snapshot history.
useGetRecoilValueInfo_UNSTABLE() provides a callback which can be used to peek at the current state and get information about atoms and selectors. For the most part this is equivalent to calling
getInfo_UNSTABLE() on a current
Snapshot, except that it can provide additional information such as the set of React components subscribing to an atom, which can change and isn't associated with a snapshot of Recoil state.