Skip to content

Onyx collection values sometimes appear as null to subscribers. #310

Closed

Description

@roryabraham

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;
}

Activity

  1. self-assigned this
    on Aug 22, 2023
  2. roryabraham commented on Aug 22, 2023

    @roryabraham
    ContributorAuthor

    Created a quick fix: #311

  3. roryabraham commented on Oct 4, 2024

    @roryabraham
    ContributorAuthor

    Whoa, how is this issue still open>

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions