1

When there are two instances of my app running, and instance A mutates an object while in online mode (with internet connection), instance B detects this and updates accordingly as desired. However, if instance A mutates data in offline mode and then goes online, instance B (online the whole time) will not detect this through the subscription. Instance B only updates when run a query. Is this expected behavior or is it likely I set up the subscription incorrectly?

GNG
  • 1,341
  • 2
  • 23
  • 50

1 Answers1

0

When you subscribe to changes that provides a notification of what changed. The changes can be local or cloud based. If you are offline and make a change with DataStore.save, then you will get a notification for that. If you are online and the app on another device changes data in the cloud you should get a notification.

Notifications are used for real-time updates. Even without notification your app will eventually receive the data. You have to choose whether you want real-time updates and then subscribe if you do.

You also have to do something to cause your app to update its display. Just because appsync updated the local copy from the cloud, or you subscribed and got a notification of change, doesn't mean your app will change what is displayed. The app has to do something to handle the change. That could be running a new query, or adding the value provided in the notification to some app data variable.

Without knowing how your app is structured it is hard to provide a better explanation.

julie
  • 172
  • 1
  • 6