interface DiscardUnsyncedChangesStrategy : SyncClientResetStrategy

Strategy that automatically resolves a Client Reset by discarding any unsynced local data but otherwise keeps the realm open. Any changes will be reported through the normal collection and object notifications.

A synced realm may need to be reset because the Device Sync encountered an error and had to be restored from a backup, or because it has been too long since the client connected to the server so the server has rotated the logs.

The Client Reset thus occurs because the server does not have all the information required to bring the client fully up to date.

The reset process for unsynced changes is as follows: when a client reset is triggered the onBeforeReset callback is invoked, providing an instance of the realm before the reset and another instance after the reset, being both read-only. Once the reset has concluded, onAfterReset will be invoked with an instance of the final realm.

In the event that discarding the unsynced data is not enough to resolve the reset the onError callback will be invoked, allowing to manually resolve the reset as it would be done in ManuallyRecoverUnsyncedChangesStrategy.onClientReset.


Link copied to clipboard
abstract fun onAfterReset(before: TypedRealm, after: MutableRealm)
Callback invoked once the Client Reset happens.
Link copied to clipboard
abstract fun onBeforeReset(realm: TypedRealm)
Callback that indicates a Client Reset is about to happen.
Link copied to clipboard
abstract fun onError(session: SyncSession, exception: ClientResetRequiredException)
Callback that indicates the seamless Client reset couldn't complete.