Skip to content

Make Onyx values update instantly #123

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

Closed
roryabraham opened this issue Mar 25, 2022 · 2 comments
Closed

Make Onyx values update instantly #123

roryabraham opened this issue Mar 25, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@roryabraham
Copy link
Contributor

Coming from: Expensify/App#8306 (comment)

Problem

Setting values in Onyx always takes at least one tick of the event loop and updates subscribers late.

Why this is important

A lot of our code could be made simpler and easier to reason about if we could safely assume that any value written in Onyx will be updated immediately.

Solution

Need to explore a bit, but probably an in-memory cache of some kind. Also need to be careful not to break stuff and to update all our tests appropriately.

@marcaaron
Copy link
Contributor

We have an in memory cache already and force the extra tick because keyChanged() used to happen after a call to AsyncStorage.getItem() (or something like that).

// Optimistically inform subscribers on the next tick
Promise.resolve().then(() => keyChanged(key, value));

@roryabraham
Copy link
Contributor Author

I do think this behavior is a bit confusing, but it's not a priority and I'm not going to work on this any time soon. Going to just close this for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants