Open
Description
We want to:
- Collect obsolete persistence as soon as possible, which is currently impossible because accessing a persisted record can only be done with the relative atom.
- Initialize asynchronous storage (IndexedDB) at application startup.
Main idea:
Persisted Atoms Registry
- It would be nice to have a separate registry with metadata about persisted atoms, so that we can manage them based on their lifetime (delete if it has expired).
- This would be an atom with a
PersistRecord
array that would also be persisted. - We will have some
init
method (or maybe just on app init) that does the following:- Loads the registry into memory from the persistence layer
- Checks all the entries in the registry:
- if the entry has expired - it should be deleted (gargabe collector).
- if the entry has not expired - it should be loaded into the memory cache.
- We can store the
loaded
status for each individual persisted atom, or maybe for the whole registry, this is negotiable.
As a result, we can do something like this when initializing the application.
await withIndexedDb.init(ctx)
// or
await withAsyncLocalStorage.init(ctx)
This way, persisted atoms are guaranteed to be initialized during rendering.
Metadata
Metadata
Assignees
Labels
No labels