-
Type: Task
-
Resolution: Done
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
Goals
Get notifications when Realm is changed on the server (related issue https://github.com/realm/realm-dotnet/issues/1840)
I'm having hard time to undestand how to get notifications to work. The https://realm.io/docs/dotnet/latest/#notifications says that synchronization context must be installed (i.e. for Android). I've set up Nito.AsyncEx (see code below), but it isn't working. I haven't managed to find any code examples, it would be nice to see working sample.
Expected Results
RealmChanged event is triggered when Realm is changed
Actual Results
RealmChanged event is not triggered when Realm is changed
Steps to Reproduce
- Create new instance in Realm cloud
- Create new Realm
- Create class and populate it with some data
- Implement client that listens to RealmChanged event
- Change value in Realm Studio (or via C# client)
Code Sample
If I change FirstName in cloud realm, RealmChanged event is not triggered
public static void Main() { AsyncContext.Run(async () => await Loop()); Console.ReadLine(); } public static async Task Loop() { // get user info & realm URL var syncConfiguration = new FullSyncConfiguration(realmUrl, user); Console.WriteLine(SynchronizationContext.Current); var realm = Realm.GetInstance(syncConfiguration); realm.RealmChanged += (s, e) => { Console.WriteLine("Realm has changed"); }; }
Version of Realm and Tooling
- Realm Cloud
- Client SDK Version: Realm 3.4.0
- Client OS & Version: Windows 10 October update