Changes API: How to subscribe to data subscription changes?

All subscription changes can be tracked by using forAllDataSubscriptions and forDataSubscription methods.

Syntax

ForAllDataSubscriptions

IObservable<DataSubscriptionChangeNotification> forAllDataSubscriptions();
Return value
IObservable<DataSubscriptionChangeNotification> Observable that allows to add subscriptions to notifications for all data subscription changes.

ForDataSubscription

IObservable<DataSubscriptionChangeNotification> forDataSubscription(long id);
Parameters
id long Id of a data subscription for which notifications will be processed.
Return value
IObservable<DataSubscriptionChangeNotification> Observable that allows to add subscriptions to notifications for a specified data subscription changes.

Example I

CleanCloseable subscription = store.
        changes()
        .forAllDataSubscriptions()
        .subscribe(Observers.create(new Action1<DataSubscriptionChangeNotification>() {
            @Override
            public void apply(DataSubscriptionChangeNotification change) {
                long subscriptionId = change.getId();

                switch (change.getType()) {
                    case SUBSCRIPTION_OPENED:
                        // do something
                        break;
                    case SUBSCRIPTION_RELEASED:
                        // do something
                        break;
                }
            }
        }));

Example II

int subscriptionId = 3;

CleanCloseable subscription2 = store.
        changes()
        .forDataSubscription(3)
        .subscribe(Observers.create(new Action1<DataSubscriptionChangeNotification>() {
            @Override
            public void apply(DataSubscriptionChangeNotification change) {
                long subscriptionId = change.getId();

                switch (change.getType()) {
                    case SUBSCRIPTION_OPENED:
                        // do something
                        break;
                    case SUBSCRIPTION_RELEASED:
                        // do something
                        break;
                }
            }
        }));