Bird
0
0

Examine this Angular RxJS snippet:

medium📝 Debug Q6 of 15
Angular - RxJS Operators
Examine this Angular RxJS snippet:
import { of, interval } from 'rxjs';
import { exhaustMap, take, map } from 'rxjs/operators';

of(1, 2).pipe(
  exhaustMap(x => interval(15).pipe(take(2), map(i => x + i)))
).subscribe(console.log);

What is the likely issue with this code?
AexhaustMap throws an error because interval is not unsubscribed
BexhaustMap processes both values concurrently, causing overlapping emissions
CexhaustMap ignores the second value because the first inner observable is still active
DexhaustMap queues the second value and processes it after the first completes
Step-by-Step Solution
Solution:
  1. Step 1: Recall exhaustMap behavior

    exhaustMap ignores new source emissions while the current inner observable is active.
  2. Step 2: Analyze code

    Since the first interval takes time, the second value (2) is ignored because the first inner observable hasn't completed.
  3. Final Answer:

    exhaustMap ignores the second value because the first inner observable is still active -> Option C
  4. Quick Check:

    exhaustMap ignores new emissions during active inner observable [OK]
Quick Trick: exhaustMap drops new emissions while busy [OK]
Common Mistakes:
MISTAKES
  • Expecting exhaustMap to queue or merge inner observables
  • Assuming exhaustMap processes all source values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes