Skip to main content

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
timeSeriesNamestringName 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
documentIdstringID of a document to subscribe to.
timeSeriesNamestringName 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
documentIdstringID 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

NameTypeDescription
TypeTimeSeriesChangeTypesTime series change type enum
NamestringTime Series Name
DocumentIdstringTime series Document Identifier
CollectionNamestringTime series document Collection Name
FromDateTimeTime series values From date
ToDateTimeTime series values To date
ChangeVectorstringTime series Change Vector

TimeSeriesChangeTypes

NameValue
None0
Put1
Delete2
Mixed3

Remarks

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