Changes API: How to subscribe to bulk insert operation changes?

ForBulkInsert method can be used to acquire notifications for bulk insert operations.

Syntax

IObservableWithTask<BulkInsertChangeNotification>
	ForBulkInsert(Guid operationId);
Parameters
operationId Guid Id of bulk insert operation, generated when bulk insert operation is created.
ReturnValue
IObservableWithTask<BulkInsertChangeNotification> Observable that allows to add subscriptions to notifications for bulk insert operation with given id.

Example

using (BulkInsertOperation bulkInsert = store.BulkInsert())
{
	IDisposable subscription = store
		.Changes()
		.ForBulkInsert(bulkInsert.OperationId)
		.Subscribe(change =>
		{
			switch (change.Type)
			{
				case DocumentChangeTypes.BulkInsertStarted:
					// do something
					break;
				case DocumentChangeTypes.BulkInsertEnded:
					// do something
					break;
				case DocumentChangeTypes.BulkInsertError:
					// do something
					break;
			}
		});

	try
	{
		for (int i = 0; i < 1000 * 1000; i++)
		{
			bulkInsert.Store(new Employee
			{
				FirstName = "FirstName #" + i,
				LastName = "LastName #" + i
			});
		}
	}
	finally
	{
		if (subscription != null)
			subscription.Dispose();
	}
}

Remarks

Information

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