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 collection values sometimes appear as null to subscribers. #310

Open
roryabraham opened this issue Aug 22, 2023 · 1 comment
Open
Assignees

Comments

@roryabraham
Copy link
Contributor

Coming from Expensify/App#25481 (comment)

Problem

Generally, to delete stuff from Onyx you set it to null. However:

  • Given a subscriber to a collection key with waitForCollectionCallback: true
  • When a collection member key is set to null
  • Then the subscriber should get the new complete collection with any null values removed

However, the subscriber is getting the new collection with a null value for the item that was meant to be deleted.

Solution

TBD. According to a contributor:

it is due to notify the subscribers with the changed values before updating the storage.

// Subscriber is a regular call to connect() and provided a callback
if (_.isFunction(subscriber.callback)) {
if (isCollectionKey(subscriber.key) && subscriber.waitForCollectionCallback) {
const cachedCollection = getCachedCollection(subscriber.key);
cachedCollection[key] = data;
subscriber.callback(cachedCollection);
continue;
}

@roryabraham
Copy link
Contributor Author

Created a quick fix: #311

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant