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

Add extension methods to add extra safety to realm subscriptions #15885

Merged
merged 5 commits into from Dec 1, 2021

Conversation

peppy
Copy link
Sponsor Member

@peppy peppy commented Dec 1, 2021

Also adjusts the naming and documentation to make it (hopefully) easier to understand what this method/process implies.

Diff for testing banned symbols:

diff --git a/osu.Game.Tests/Database/RealmLiveTests.cs b/osu.Game.Tests/Database/RealmLiveTests.cs
index 9b6769b788..6585d2e90d 100644
--- a/osu.Game.Tests/Database/RealmLiveTests.cs
+++ b/osu.Game.Tests/Database/RealmLiveTests.cs
@@ -2,6 +2,7 @@
 // See the LICENCE file in the repository root for full licence text.
 
 using System;
+using System.Collections.Generic;
 using System.Diagnostics;
 using System.Linq;
 using System.Threading.Tasks;
@@ -208,7 +209,13 @@ public void TestLiveAssumptions()
 
                 using (var updateThreadContext = realmFactory.CreateContext())
                 {
-                    updateThreadContext.All<RealmBeatmap>().QueryAsyncWithNotifications(gotChange);
+                    IList<RealmBeatmap> testList = updateThreadContext.All<RealmBeatmap>().ToList();
+                    IQueryable<RealmBeatmap> testQueryable = updateThreadContext.All<RealmBeatmap>().AsQueryable();
+
+                    testList.SubscribeForNotifications(gotChange);
+                    testQueryable.SubscribeForNotifications(gotChange);
+
+                    updateThreadContext.All<RealmBeatmap>().SubscribeForNotifications(gotChange);
                     ILive<RealmBeatmap>? liveBeatmap = null;
 
                     Task.Factory.StartNew(() =>

Also adjusts the naming and documentation to make it (hopefully) easier
to understand what this method/process implies.
@peppy peppy added realm deals with local realm database type:code-quality labels Dec 1, 2021
@smoogipoo smoogipoo merged commit 85c3123 into ppy:master Dec 1, 2021
@bdach bdach mentioned this pull request Dec 1, 2021
6 tasks
@peppy peppy deleted the realm-subscribe-helper-methods branch December 3, 2021 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
realm deals with local realm database size/L type:code-quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants