Skip to content

Missing updates from the Realtime Database #321

@KaipoCraft

Description

@KaipoCraft

Hi! Thank y'all for this project. I'm using the Subscribe() function and it seems like it occasionally misses deletion events. I set up this simple function to update a dictionary. Is this the proper way to interact with this? What might be a more thread-safe version of this assuming that it's a race condition?

    .AsObservable<JToken>()
    .Subscribe(d =>
    {
        if (d.EventType == Firebase.Database.Streaming.FirebaseEventType.InsertOrUpdate)
        {
            if (currentItems.ContainsKey(d.Key))
            {
                // Update item in dictionary
                currentItems[d.Key] = d.Object;
            }
            else
            {
                // Add item to dictionary
                currentItems.Add(d.Key, d.Object);
            }
        }
        else if (d.EventType == Firebase.Database.Streaming.FirebaseEventType.Delete)
        {
            // Remove item from dictionary
            currentItems.Remove(d.Key);
        }
    });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions