Bird
0
0

What is wrong with this forkJoin usage?

medium📝 Debug Q7 of 15
Angular - RxJS Operators
What is wrong with this forkJoin usage?
import { forkJoin, interval } from 'rxjs';

const obs1 = interval(1000);
const obs2 = interval(2000);

forkJoin([obs1, obs2]).subscribe(console.log);
AforkJoin will never emit because interval observables never complete
BforkJoin requires observables to emit strings only
Cinterval cannot be used with forkJoin due to timing issues
Dsubscribe callback is missing parentheses
Step-by-Step Solution
Solution:
  1. Step 1: Understand interval observable behavior

    interval creates an observable that emits indefinitely and never completes on its own.
  2. Step 2: forkJoin requires completion

    forkJoin waits for all observables to complete before emitting, so with infinite observables it never emits.
  3. Final Answer:

    forkJoin will never emit because interval observables never complete -> Option A
  4. Quick Check:

    forkJoin requires completion = B [OK]
Quick Trick: forkJoin waits for completion; infinite observables block emission [OK]
Common Mistakes:
MISTAKES
  • Expecting forkJoin to emit with infinite observables
  • Confusing emission with completion
  • Incorrect subscribe callback syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes