All quizzesHard
Marble Testing — Series 2
Preview — 3 of 10 questions
Where does this error go?
javascript
source$.pipe(catchError(() => of(null))).subscribe((v) => {
throw new Error('boom'); // thrown by the consumer, not the source
});AInto the catchError above, which returns null
BNowhere; RxJS discards subscriber errors
CIt is reported as an unhandled error — operators only handle errors travelling down from the source, and by the time next runs, the chain is behind it
DInto the subscription's error callback
In what order do the finalize callbacks run when the source completes?
javascript
source$.pipe(
finalize(() => console.log('A')),
map((x) => x),
finalize(() => console.log('B')),
).subscribe();AB then A — teardown unwinds from the subscriber back towards the source, the reverse of the subscription order
BA then B
COnly B, since it is closest to the subscriber
DThe order is not defined
What is the minimal correct shape?
javascript
export function retryOnServerError<T>(count = 3): MonoTypeOperatorFunction<T> {
return (source) =>
source.pipe(
retry({ count, delay: (e, i) => (e.status >= 500 ? timer(2 ** i * 500) : throwError(() => e)) }),
);
}AA class extending Observable with a lift method
BA function that subscribes to the source and returns a Subscription
CA Subject subclass
DA function returning an OperatorFunction<T, R> — that is, (source: Observable<T>) => Observable<R> — usually composed from existing operators with pipe()
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.