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

Missing updates from the Realtime Database #321

Open
KaipoCraft opened this issue May 30, 2024 · 0 comments
Open

Missing updates from the Realtime Database #321

KaipoCraft opened this issue May 30, 2024 · 0 comments

Comments

@KaipoCraft
Copy link

KaipoCraft commented May 30, 2024

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