Table of Contents

Class BehaviorSubject

Namespace
Bonsai.Reactive
Assembly
Bonsai.Core.dll

Represents an expression builder that broadcasts the latest value of an observable sequence to all subscribed and future observers using a shared subject.

Marble diagram

BehaviorSubject stores and passes the latest value emitted by the source sequence to each subscribed observer, and then continues to emit any subsequent values.

Any observers which subscribe later will immediately receive the latest stored value. However, if the source sequence terminates with an error, BehaviorSubject will not emit any values but will pass along the error notification to all subsequent observers.

Warning

BehaviorSubject is designed to multicast and share state updates from multiple sources, like a global variable. Because of this, even if one of the source sequences emitting values to BehaviorSubject terminates successfully, the BehaviorSubject will not send a termination message to any subscribed observers, but will remain active until the enclosing workflow scope is terminated to allow other sources to update the shared state.

[WorkflowElementIcon("BehaviorSubject")]
public class BehaviorSubject : SubjectBuilder, IExpressionBuilder, INamedElement
Inheritance
BehaviorSubject
Implements
Inherited Members
Extension Methods

Methods

BuildSubject(Expression)

When overridden in a derived class, returns the expression that creates the shared subject.

protected override Expression BuildSubject(Expression expression)

Parameters

expression Expression

The expression representing the observable input sequence.

Returns

Expression

The Expression that creates the shared subject.