Javatpoint Logo
Javatpoint Logo

RxJS publishLast() Multicasting Operator

RxJS publishLast() operator is a multicasting operator used to return a connectable observable sequence that shares a single subscription to the underlying sequence, containing only the last notification.

The RxJS publishLast() operator is similar to the publish operator, but it waits until the source observable completes and stores the last emitted value. Similarly to publishReplay and publishBehavior operator, this operator also keeps storing the last value even if it has no more subscribers. If subsequent subscriptions happen, they will immediately get that last stored value and complete it.

Syntax:

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

Parameter Explanation

There is no such parameter that we have to explain.

Return value

The RxJS publishLast() operator returns an observable sequence that contains the elements of a sequence produced by multicasting the source sequence.

Let us see some examples of the RxJS publishLast() operator to understand it clearly.

Example 1

Output:

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

RxJS publishLast() Multicasting Operator

Example 2

Output:

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

RxJS publishLast() Multicasting Operator
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