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

IRealmCollection SubscribeForNotifications not working!!!

      What happened?

      I used SubscribeForNotifications with IRealmCollection. After packaging the app into an MSIX for installation, I didn't receive any notifications when adding a new record. However, during local debugging, I could receive notifications.

      Repro steps

      1. Implement SubscribeForNotifications on ViewModel init.
      2. Add a new record.
      3. SubscribeForNotifications didn't receive any notifications.

      Version

      8.0

      What Atlas Services are you using?

      Local Database only

      What type of application is this?

      Other

      Client OS and version

      Windows 10 22H2 build 19045.4291

      Code snippets

      DataService.cs

      public class DataService
      {
          public static DataService Instance { get; } = new DataService();
      
          private readonly Realm LocalRealm;
      
          public IRealmCollection<Device> DeviceList { get; }
      
          public async Task<Device> AddDevice(Device device)
          {
              return await LocalRealm.WriteAsync(() =>
              {
                  return LocalRealm.Add(device, true);
              });
          }
      }
      

      ViewModel.cs

      public partial class DeviceListViewModel : ObservableObject
      {
          public ObservableCollection<Models.Device> DeviceList { get; } = [];
      
          private IDisposable deviceListNotifyToken;
      
          public DeviceListViewModel()
          {
              deviceListNotifyToken = DataService.Instance.DeviceList.SubscribeForNotifications((list, changeSet) =>
              {
                  if (changeSet != null)
                  {
                      foreach (var idx in changeSet.InsertedIndices)
                          DeviceList.Insert(idx, list[idx]);
      
                      foreach (var idx in changeSet.ModifiedIndices)
                      {
                          var item = list[idx];
                          DeviceList.RemoveAt(idx);
                          DeviceList.Insert(idx, item);
                      }
      
                      foreach (var idx in changeSet.DeletedIndices)
                          DeviceList.RemoveAt(idx);
                  }
      
                  OnPropertyChanged();
              });
          }
      }
      

      Stacktrace of the exception/crash you're getting

      Unable to find source-code formatter for language: shell. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      No crash.
      

      Relevant log output

      Unable to find source-code formatter for language: shell. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      No log.
      

            Assignee:
            nikola.irinchev@mongodb.com Nikola Irinchev
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: