Add extension methods to add extra safety to realm subscriptions

Also adjusts the naming and documentation to make it (hopefully) easier
to understand what this method/process implies.
This commit is contained in:
Dean Herbert
2021-12-01 15:09:51 +09:00
parent 7d0135063e
commit 4306420922
4 changed files with 111 additions and 6 deletions

View File

@ -5,8 +5,8 @@ using System;
using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
using osu.Game.Database;
using osu.Game.Models;
using Realms;
#nullable enable
@ -48,7 +48,7 @@ namespace osu.Game.Tests.Database
using (var context = realmFactory.CreateContext())
{
var subscription = context.All<RealmBeatmap>().SubscribeForNotifications((sender, changes, error) =>
var subscription = context.All<RealmBeatmap>().QueryAsyncWithNotifications((sender, changes, error) =>
{
using (realmFactory.CreateContext())
{
@ -61,7 +61,7 @@ namespace osu.Game.Tests.Database
{
}
subscription.Dispose();
subscription?.Dispose();
}
Assert.IsTrue(callbackRan);