Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Onyx.clear() will wipe Onyx.set() from Storage #144

Open
marcaaron opened this issue May 27, 2022 · 0 comments
Open

Onyx.clear() will wipe Onyx.set() from Storage #144

marcaaron opened this issue May 27, 2022 · 0 comments

Comments

@marcaaron
Copy link
Contributor

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant