Uploaded image for project: 'Realm .NET SDK'
  1. Realm .NET SDK
  2. RNET-40

Realm change event & synchronization context

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Unknown 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

      1. Create new instance in Realm cloud
      2. Create new Realm
      3. Create class and populate it with some data
      4. Implement client that listens to RealmChanged event
      5. 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

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: