Search in sources :

Example 1 with MutableSubscriptionSet

use of io.realm.mongodb.sync.MutableSubscriptionSet in project realm-java by realm.

the class SyncObjectServerFacade method downloadInitialFlexibleSyncData.

@Override
public void downloadInitialFlexibleSyncData(Realm realm, RealmConfiguration configuration) {
    if (configuration instanceof SyncConfiguration) {
        SyncConfiguration syncConfig = (SyncConfiguration) configuration;
        if (syncConfig.isFlexibleSyncConfiguration()) {
            SyncConfiguration.InitialFlexibleSyncSubscriptions handler = syncConfig.getInitialSubscriptionsHandler();
            if (handler != null) {
                SubscriptionSet subscriptions = realm.getSubscriptions();
                subscriptions.update(new SubscriptionSet.UpdateCallback() {

                    @Override
                    public void update(MutableSubscriptionSet subscriptions) {
                        handler.configure(realm, subscriptions);
                    }
                });
                if (!subscriptions.waitForSynchronization()) {
                    throw new IllegalStateException("Realm couldn't be fully opened because " + "flexible sync encountered an error when bootstrapping initial" + "subscriptions: " + subscriptions.getErrorMessage());
                }
            }
        }
    }
}
Also used : SubscriptionSet(io.realm.mongodb.sync.SubscriptionSet) MutableSubscriptionSet(io.realm.mongodb.sync.MutableSubscriptionSet) MutableSubscriptionSet(io.realm.mongodb.sync.MutableSubscriptionSet) SyncConfiguration(io.realm.mongodb.sync.SyncConfiguration)

Aggregations

MutableSubscriptionSet (io.realm.mongodb.sync.MutableSubscriptionSet)1 SubscriptionSet (io.realm.mongodb.sync.SubscriptionSet)1 SyncConfiguration (io.realm.mongodb.sync.SyncConfiguration)1