Consider the code snippet below:
import { interval, race, Subject } from 'rxjs';
import { mapTo } from 'rxjs/operators';
const a$ = new Subject<number>();
const b$ = interval(1000).pipe(mapTo(1));
race([a$, b$]).subscribe(console.log);
a$.subscribe({complete: () => console.log('a$ completed!')});
[1,2,3,4,5,6,7].map(i => a$.next(i));
When running this code, the output in the console is shown as 1...7. Initially, my expectation was to see an output of 1, 2, 3, 4, 5, 6, 7, followed by multiple occurrences of value 1 from observable b$. However, it seems that after all values are emitted from array a$, the values from b$ do not get passed. So, why is this happening? Does the race operator somehow recognize that a$ has finished emitting values, preventing b$ from continuing?