Javatpoint Logo
Javatpoint Logo

RxJS publishReplay() Multicasting Operator

RxJS publishReplay() operator is a multicasting operator that uses behavior subject, wherein it can buffer the values and replay the same to the new subscribers and returns ConnectableObservable. Here, the connect() method has to be used to subscribe to the observable created.

Syntax:

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

Or

Parameter Explanation

  • bufferSize: It is an optional. Its default value is undefined. Type: number.
  • windowTime: It is an optional. Its default value is undefined. Type: number.
  • selectorOrScheduler: It is an optional. Its default value is undefined. Type: SchedulerLike | OperatorFunction.
  • scheduler: It is an optional. Its default value is undefined. Type: SchedulerLike.

Return value

The RxJS publishReplay() operator returns a ConnectableObservable.

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

Example

Output:

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

RxJS publishReplay() Multicasting Operator
Next TopicRxJS Operators





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA