Docs Menu

Interface DiscardUnsyncedChangesStrategy

On this page

  • io.realm.mongodb.sync
  • Method Summary
  • Inherited Methods
  • Method Detail
  • onAfterReset
  • onBeforeReset
  • onError

Implemented interfaces:

Strategy that automatically resolves a Client Reset by discarding any unsynced data, but otherwise keep 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 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 the full information required to bring the Client fully up to date.

The discard unsynced changes reset process is as follows: when a client reset is triggered the onBeforeReset(Realm) callback is invoked, providing an instance of the Realm before the reset and another after the reset, both read-only. Once the reset has concluded the callback onAfterReset(Realm, Realm) would 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(SyncSession, ClientResetRequiredError) would be invoked, it allows to manually resolve the reset as it would be done in ManuallyRecoverUnsyncedChangesStrategy.onClientReset(SyncSession, ClientResetRequiredError) .

Modifier and Type
Method and Description
public void
Realm before,
Realm after
)

Callback invoked once the Client Reset happens.

public void

Callback that indicates a Client Reset is about to happen.

public void

Callback that indicates the seamless Client reset couldn't complete.

public void onAfterReset (
Realm before,
Realm after
)

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

Parameters

  • before - Realm frozen Realm in the before after the reset.
  • after - Realm Realm after the reset.
public void onBeforeReset (
Realm realm
)

Callback that indicates a Client Reset is about to happen. It provides with a frozen instance of the Realm that is will be reset.

Parameters

  • realm - frozen Realm in its state before the reset.
public void onError (
)

Callback that indicates the seamless Client reset couldn't complete. It should be handled as ManuallyRecoverUnsyncedChangesStrategy.onClientReset(SyncSession, ClientResetRequiredError) .

Parameters

←  Enum ConnectionStateInterface ManuallyRecoverUnsyncedChangesStrategy →
Give Feedback
© 2022 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2022 MongoDB, Inc.