Changes API: How to Subscribe to Time Series Changes


  • Use the following methods to subscribe to Time Series Changes:

    • ForTimeSeries
      Track all time series with a given name
    • ForTimeSeriesOfDocument
      Overload #1: Track a specific time series of a chosen document
      Overload #2: Track any time series of a chosen document
    • ForAllTimeSeries
      Track all time series
  • In this page:


ForTimeSeries

Subscribe to changes in all time-series with a given name, no matter which document they belong to, using the ForTimeSeries method.

Syntax

IChangesObservable<TimeSeriesChange> ForTimeSeries(string timeSeriesName);
Parameters
timeSeriesName string Name of a time series to subscribe to.
Return Value
IChangesObservable<TimeSeriesChange> Observable that allows to add subscriptions to time series notifications.

Example

IDisposable subscription = store
    .Changes()
    .ForTimeSeries("Likes")
    .Subscribe
        (change =>
        {
            switch (change.Type)
            {
                case TimeSeriesChangeTypes.Delete:
                    // do something
                break;
            }
        });

ForTimeSeriesOfDocument

Use ForTimeSeriesOfDocument to subscribe to changes in time series of a chosen document.

  • Two overload methods allow you to
    • Track a specific time series of the chosen document
    • Track any time series of the chosen document

Overload #1

Use this ForTimeSeriesOfDocument overload to track changes in a specific time series of the chosen document.

Syntax

IChangesObservable<TimeSeriesChange> ForTimeSeriesOfDocument(string documentId, string timeSeriesName);
Parameters
documentId string ID of a document to subscribe to.
timeSeriesName string Name of a time series to subscribe to.
Return Value
IChangesObservable<TimeSeriesChange> Observable that allows to add subscriptions to time series notifications.

Example

IDisposable subscription = store
    .Changes()
    .ForTimeSeriesOfDocument("companies/1-A", "Likes")
    .Subscribe
        (change =>
        {
            switch (change.Type)
            {
                case TimeSeriesChangeTypes.Delete:
                    // do something
                break;
            }
        });

Overload #2

Use this ForTimeSeriesOfDocument overload to track changes in any time series of the chosen document.

Syntax

IChangesObservable<TimeSeriesChange> ForTimeSeriesOfDocument(string documentId);
Parameters
documentId string ID of a document to subscribe to.
Return Value
IChangesObservable<TimeSeriesChange> Observable that allows to add subscriptions to time series notifications.

Example

IDisposable subscription = store
    .Changes()
    .ForTimeSeriesOfDocument("companies/1-A")
    .Subscribe
        (change =>
        {
            switch (change.Type)
            {
                case TimeSeriesChangeTypes.Delete:
                    // do something
                break;
            }
        });

ForAllTimeSeries

Subscribe to changes in all time-series using the ForAllTimeSeries method.

Syntax

IChangesObservable<TimeSeriesChange> ForAllTimeSeries();
Return Value
IChangesObservable<TimeSeriesChange> Observable that allows to add subscriptions to time series notifications.

Example

IDisposable subscription = store
    .Changes()
    .ForAllTimeSeries()
    .Subscribe
        (change =>
        {
            switch (change.Type)
            {
                case TimeSeriesChangeTypes.Delete:
                    // do something
                break;
            }
        });

TimeSeriesChange

Name Type Description
Type TimeSeriesChangeTypes Time series change type enum
Name string Time Series Name
DocumentId string Time series Document Identifier
CollectionName string Time series document Collection Name
From DateTime Time series values From date
To DateTime Time series values To date
ChangeVector string Time series Change Vector

TimeSeriesChangeTypes

Name Value
None 0
Put 1
Delete 2
Mixed 3

Remarks

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