Closed cmelchior closed 2 years ago
Working API:
abstract class BaseRealm { @ObjectServer @Beta public SubscriptionSet getSubscriptions() { ... } } @ObjectServer @Beta public interface Subscription { static Subscription create(String name, RealmQuery query) { ... } static Subscription create(RealmQuery query) { ... } @Nullable Date getCreatedAt(); @Nullable Date getUpdatedAt(); @Nullable String getName(); String getObjectType(); public String getQuery(); } @ObjectServer @Beta public interface SubscriptionSet extends Iterable<Subscription> { public enum State { UNCOMMITTED(OsSubscriptionSet.STATE_VALUE_UNCOMMITTED), PENDING(OsSubscriptionSet.STATE_VALUE_PENDING), BOOTSTRAPPING(OsSubscriptionSet.STATE_VALUE_BOOTSTRAPPING), COMPLETE(OsSubscriptionSet.STATE_VALUE_COMPLETE), ERROR(OsSubscriptionSet.STATE_VALUE_ERROR), SUPERCEDED(OsSubscriptionSet.STATE_VALUE_SUPERCEDED); public static State fromNativeValue(long value) { ... } } @Nullable Subscription find(RealmQuery query); @Nullable Subscription findByName(String name); State getState(); int size(); @Nullable String getErrorMessage(); boolean waitForSynchronization(); boolean waitForSynchronization(Long timeOut, TimeUnit unit); RealmAsyncTask waitForSynchronizationAsync(Callback callback); RealmAsyncTask waitForSynchronizationAsync(Long timeOut, TimeUnit unit, Callback callback); SubscriptionSet update(UpdateCallback action); RealmAsyncTask updateAsync(UpdateAsyncCallback callback); void refresh(); interface UpdateCallback { void update(MutableSubscriptionSet subscriptions); } interface UpdateAsyncCallback extends UpdateCallback { void onSuccess(SubscriptionSet subscriptions); void onError(Throwable exception); } interface Callback { void onStateChange(SubscriptionSet subscriptions); void onError(Throwable e); } } @ObjectServer @Beta public interface MutableSubscriptionSet extends SubscriptionSet { Subscription add(Subscription subscription); Subscription addOrUpdate(Subscription subscription); boolean remove(Subscription subscription); boolean remove(String name); boolean removeAll(String objectType); <T extends RealmModel> boolean removeAll(Class<T> clazz); boolean removeAll(); }
I should have addressed all comments. Please take another look.
Working API: