Synchronizes atom state to the localStorage with a given name
withSesssionStorage
Synchronizes atom state to the sessionsStorage with a given name
withBroadcastChannel
The main goal of this adapter is to synchronize atom between tabs without polluting localStorage
You can also give an instance of BroadcastChannel
withIndexedDb
IMPORTANT: The state currently flicks (goes from null to actual value) on the first page load (due to asynchronous nature of IndexedDB and current synchronous architecture of @reatom/persist)
The main goal of this adapter is to persist atom’s state to IndexedDB. withIndexedDb does not currently support rich IndexedDB features such as indexing, transactions and migrations. It uses IndexedDB as a key-value storage, which is preferable over localStorage for large data (over a couple of megabytes).
You can also specify a custom database name and a custom `BroadcastChannel’ that will be used to synchronize the data in real time.
If you want to avoid flickering, all you have to do is add a small delay after the atom is connected. Subscribe / spy the data atom, wait the ready atom and then use the actual data.