Javatpoint Logo
Javatpoint Logo

RxJS race() Join Operator

The RxJS race() operator is a join operator that creates an output Observable, which shows the exact mirror copy of the first source observable.

In other words, we can say that the race() operator emits the first used operator as a result.

Syntax:

Following is the syntax of the race() operator:

Parameter Explanation

observable: It specifies that the argument for this operator is an array of Observable.

Return value

The race() operator's return value is a single observable that will be an exact mirror copy of the first source observable.

Let us see some examples of race() operator to understand it clearly.

Example 1 (Simple example)

Output:

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

RxJS race() Join Operator

In the above example, you can see that the race() operator has displayed the exact same first list as result in the output.

Example 2 (Race with 4 observables)

Output:

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

RxJS race() Join Operator

Example 3 (race with an error)

Output:

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

RxJS race() Join Operator

Here, you can see that it has thrown an error and does not entertain the other variables.


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