`Onyx.clear()` will wipe `Onyx.set()` from `Storage`
Opened this issue · 0 comments
marcaaron commented
cc @neil-marcellini and coming from #129 (comment)...
Unsure if there is any observable problem with this at the moment, but it just doesn't seem like the expected behavior.
This is how this code runs today...
const promises = [];
promises.push(Onyx.clear());
promises.push(Onyx.set('test', {someValue: 'test'});
Promise.all(promises)
.then(() => {
Storage.getItem('test').then((val) => console.log(val)) // null
});
The cache values end up correct, but the storage values are not. The behavior is documented but we might want to fix it eventually.
One idea I had:
- Set an internal flag that
Onyx.clear()
is still running and hasn't fully cleared storage. - While that happens batch any new writes to storage or flag which keys need to be saved after we are done, but allow cached values to be set, merged, whatever.
- Once
Storage.clear()
is done we can sync up any queued "writes" with the values in the cache.