Javatpoint Logo
Javatpoint Logo

RxJS publishBehaviour() Multicasting Operator

RxJS publishBehaviour() operator is a multicasting operator that returns a ConnectableObservable by using the BehaviourSubject. Here, the connect() method has to be used to subscribe to the observable created.

In other words, we can say that the RxJS publishBehaviour() operator returns ConnectableObservable and requires to use connect() method to subscribe to the observables.

Syntax:

Following is the syntax of the RxJS publishBehaviour() multicasting operator:

Or

Parameter Explanation

There is no such parameter that we have to explain.

Return value

The RxJS publishBehaviour() operator returns a ConnectableObservable that causes the source observable to emit items to its observers when the connection is established.

Let us see an example of the RxJS publishBehaviour() operator to understand it clearly.

Example

Output:

After executing the above example, you will see the following result:

RxJS publishBehaviour() Multicasting Operator

In the above example, you can see that the default value is displayed first, and later the values from the observable are displayed according to the setting in the example.


Next TopicRxJS Operators




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA