see on GitHub

Changes API : What is Changes API?

The RavenDB client offers a push notification feature that allows you to receive messages from a server about events that occurred there. You are able to subscribe to events for all documents, indexes and operations as well as to indicate a particular one that you are interested in. This mechanism lets you notify users if something has changed without the need to do any expensive polling.

Accessing Changes API

The changes subscription is accessible by a document store through its IDatabaseChanges interface.

IDatabaseChanges Changes(string database = null);

Parameters
database string Name of database to open changes API for. If null, the Database configured in DocumentStore will be used.
Return value
IDatabaseChanges Instance implementing IDatabaseChanges interface.

Connection interface

IDatabaseChanges inherits from IConnectableChanges<TChanges> interface that represent the connection.

public interface IConnectableChanges<TChanges> : IDisposable
    where TChanges : IDatabaseChanges
{
    // returns state of the connection
    bool Connected { get; }

    // A task that ensures that the connection to the server was established.
    Task<TChanges> EnsureConnectedNow();

    //An event handler to detect changed to the connection status
    event EventHandler ConnectionStatusChanged;

    //An action to take if an error occured in the connection to the server
    event Action<Exception> OnError;
}

Subscriptions

In order to retrieve notifications you have to subscribe to server-side events by using one of the following methods:

Unsubscribing

In order to end subscription (stop listening for particular notifications) you must Dispose it.

IDatabaseChanges subscription = store.Changes();
await subscription.EnsureConnectedNow();
subscription.ForAllDocuments().Subscribe(change => Console.WriteLine("{0} on document {1}", change.Type, change.Id));

try
{
    // application code here
}
finally
{
    if (subscription != null)
        subscription.Dispose();
}

Remarks

Information

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