Bird
0
0

Which of the following correctly describes this usage of tap?

medium📝 Debug Q7 of 15
Angular - RxJS Operators
Which of the following correctly describes this usage of tap?
import { of } from 'rxjs';
import { tap } from 'rxjs/operators';

of(1, 2, 3).pipe(
  tap({
    next: x => console.log(x),
    error: err => console.error(err)
  })
).subscribe();
Atap accepts an object with next and error handlers
BMissing complete observer with complete handler
Csubscribe is missing error handler
Dtap must be used after subscribe
Step-by-Step Solution
Solution:
  1. Step 1: Check tap argument types

    tap accepts a function, multiple functions (next, error, complete), or an object (PartialObserver) with next, error, complete properties.
  2. Step 2: Verify the code

    This code passes a valid PartialObserver object to tap for side effects on next and error events.
  3. Final Answer:

    tap accepts an object with next and error handlers -> Option A
  4. Quick Check:

    tap accepts PartialObserver objects [OK]
Quick Trick: tap takes functions or PartialObserver objects [OK]
Common Mistakes:
MISTAKES
  • Thinking tap does not accept observer objects
  • Confusing tap with subscribe argument
  • Expecting tap to handle complete

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes