Table of Contents

Class BufferTrigger

Namespace
Bonsai.Reactive
Assembly
Bonsai.Core.dll

Represents an operator that projects each element of an observable sequence into zero or more buffers created when the second sequence emits a notification.

Marble diagram

BufferTrigger groups the notifications of the source sequence into chunks, where the opening of each chunk is triggered by the notifications of the second sequence. The rules for closing each buffer can be specified using the Count and TimeSpan properties.

If neither buffer count nor buffer time span are specified, chunks will be strictly non-overlapping, with the previous chunk being closed when a new chunk is created. In this case, and only this case, the first chunk is also created immediately at the start of the sequence.

If the Count property or the TimeSpan property is specified, then a new chunk is created when the second sequence emits a notification, and it is automatically closed after either the specified number of elements is collected or the specified time span elapses. If a new chunk is created before the previous chunk is closed, then chunks will overlap, and any elements emitted during this period will be included in both buffers. If at any moment there is no open buffer, elements emitted from the source sequence will be dropped.

[Combinator]
public class BufferTrigger
Inheritance
BufferTrigger
Inherited Members

Properties

Count

Gets or sets the maximum number of elements in each buffer.

public int? Count { get; set; }

Property Value

int?

Remarks

If no value is specified, the buffer will have its length specified by either a maximum time span, or the boundary indicated by a notification from the second sequence.

TimeSpan

Gets or sets the time length of each buffer.

public TimeSpan? TimeSpan { get; set; }

Property Value

TimeSpan?

Remarks

If no value is specified, the buffer will have its length specified by either a maximum number of elements, or the boundary indicated by a notification from the second sequence.

Methods

Process<TSource, TBufferOpening>(IObservable<TSource>, IObservable<TBufferOpening>)

Projects each element of an observable sequence into zero or more buffers created when a second sequence emits a notification.

public IObservable<IList<TSource>> Process<TSource, TBufferOpening>(IObservable<TSource> source, IObservable<TBufferOpening> bufferOpenings)

Parameters

source IObservable<TSource>

The source sequence to produce buffers over.

bufferOpenings IObservable<TBufferOpening>

The sequence of buffer openings. If no maximum length is specified, the current buffer is closed and a new buffer is opened upon receiving a notification from this sequence.

Returns

IObservable<IList<TSource>>

An observable sequence of buffers.

Type Parameters

TSource

The type of the elements in the source sequence.

TBufferOpening

The type of the elements in the bufferOpenings sequence.