Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

raceWith

Creates an Observable that mirrors the first source Observable to emit a next, error or complete notification from the combination of the Observable to which the operator is applied and supplied Observables.

Example

import { interval, map, raceWith } from 'rxjs';

const obs1 = interval(7000).pipe(map(() => 'slow one'));
const obs2 = interval(3000).pipe(map(() => 'fast one'));
const obs3 = interval(5000).pipe(map(() => 'medium one'));

obs1
  .pipe(raceWith(obs2, obs3))
  .subscribe(winner => console.log(winner));

// Outputs
// a series of 'fast one'
function raceWith<T, A extends readonly unknown[]>(...otherSources: [...ObservableInputTuple<A>]): OperatorFunction<T, T | A[number]>;
§
raceWith<T, A extends readonly unknown[]>(...otherSources: [...ObservableInputTuple<A>]): OperatorFunction<T, T | A[number]>
[src]

§Type Parameters

§
A extends readonly unknown[]
[src]

§Parameters

§
...otherSources: [...ObservableInputTuple<A>] optional
[src]

Sources used to race for which Observable emits first.

§Return Type

§
OperatorFunction<T, T | A[number]>
[src]

A function that returns an Observable that mirrors the output of the first Observable to emit an item.