RecoverUnsyncedChangesStrategy

Strategy that attempts to automatically recover any unsynced changes during a Client Reset.

A synced realm may need to be reset because the MongoDB Realm Server 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 recover unsynced changes process is as follows: when a Client Reset is received by the client the onBeforeReset callback is invoked, after which the client will be reset. Once the reset has concluded the onAfterReset callback will be invoked if the changes have been recovered successfully.

In the event that the client reset could not discard the unsynced data onManualResetFallback will be invoked. This allows to manually resolve the reset as it would have been done by ManuallyRecoverUnsyncedChangesStrategy.onClientReset.

Functions

Link copied to clipboard
abstract fun onAfterReset(before: TypedRealm, after: MutableRealm)

Callback invoked once the Client Reset happens. It receives two Realm instances: a frozen one displaying the state before the reset and a regular one with the current state that can be used to recover objects from the reset.

Link copied to clipboard
abstract fun onBeforeReset(realm: TypedRealm)

Callback that indicates a Client Reset is about to happen. It receives a frozen instance of the realm that will be reset.

Link copied to clipboard

Callback that indicates the Client reset failed to complete. It should be handled as in ManuallyRecoverUnsyncedChangesStrategy.onClientReset.