RxJS & Observables Flashcards
7 cards from real Angular Web Framework practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 RxJS & Observables flashcards as text
What is the correct way to multicast an Observable to multiple subscribers using a single execution in RxJS?
Answer: Use the share() operator
share() wraps the source in a Subject and multicasts it so all subscribers share one underlying execution rather than triggering separate ones.
Which operator is best suited for sequential HTTP requests where the order of results must match the order of source emissions?
Answer: concatMap
concatMap subscribes to each inner Observable only after the previous one completes, preserving order at the cost of parallelism.
What does `BehaviorSubject` require that a regular `Subject` does not?
Answer: An initial value provided at construction time
BehaviorSubject must be initialized with a seed value and always emits the most recent value to new subscribers immediately upon subscription.
Which RxJS operator emits only the first value that passes a predicate, then completes?
Answer: first
first() emits the first value matching an optional predicate and immediately completes the stream.
How does `mergeMap` differ from `concatMap` when handling multiple concurrent inner Observables?
Answer: mergeMap subscribes to all inner Observables simultaneously; concatMap queues them
mergeMap subscribes to every inner Observable immediately without waiting, allowing concurrent execution unlike concatMap's sequential approach.
What is the difference between `Subject` and `Observable` in RxJS?
Answer: Subject is both an Observable and an Observer, allowing external code to push values
A Subject implements both the Observable and Observer interfaces, so external code can call next(), error(), or complete() on it directly.
Which operator converts a higher-order Observable (Observable of Observables) into a first-order Observable using merge strategy?
Answer: mergeAll
mergeAll subscribes to each inner Observable as it arrives and merges their emissions concurrently into a single stream.