Changes API: How to subscribe to data subscription changes?

All subscription changes can be tracked by using ForAllDataSubscriptions and ForDataSubscription methods.

Syntax

ForAllDataSubscriptions

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

ForDataSubscription

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

Example I

IDisposable subscription = store
	.Changes()
	.ForAllDataSubscriptions()
	.Subscribe(
		change =>
		{
			var subscriptionId = change.Id;

			switch (change.Type)
			{
				case DataSubscriptionChangeTypes.SubscriptionOpened:
					// do something
					break;
				case DataSubscriptionChangeTypes.SubscriptionReleased:
					// do something
					break;
			}
		});

Example II

var subscriptionId = 3;

IDisposable subscription = store
	.Changes()
	.ForDataSubscription(subscriptionId)
	.Subscribe(
		change =>
		{
			switch (change.Type)
			{
				case DataSubscriptionChangeTypes.SubscriptionOpened:
					// do something
					break;
				case DataSubscriptionChangeTypes.SubscriptionReleased:
					// do something
					break;
			}
		});

Remarks

Information

To get more method overloads, especially the ones supporting delegates, please add Reactive Extensions package to your project.