All quizzesMedium
Operators & Subjects — Series 3
Preview — 3 of 10 questions
Compared to retry(3), what does calling retry() with no argument do on a source that keeps failing?
javascript
this.http.get('/api/flaky').pipe(retry()).subscribe();AIt behaves identically to not using retry at all — an argument is required for it to have any effect
BIt retries exactly once, the same as retry(1)
CIt retries indefinitely — with no count specified, retry() re-subscribes to the source every single time it errors, forever, as long as it keeps failing. On a request that's permanently broken (a 404, a bad payload) rather than transiently flaky, this can hammer the server in an infinite loop rather than eventually giving up
DIt waits for user confirmation before each retry attempt
What does this log?
javascript
of(1, 2, 3, 4).pipe(pairwise()).subscribe(v => console.log(v));A[1, 2], [2, 3], [3, 4] — pairwise() emits the previous and current value together as a two-element array, once there have been at least two emissions; the very first value alone (1) produces no output on its own, since there's no "previous" yet to pair it with
B[1, 2, 3, 4] — all values collected into a single array
C1, 2, 3, 4 — identical to not using pairwise() at all
D[1, 1], [2, 2], [3, 3], [4, 4] — each value paired with itself
sortOrder$ is a Subject that only emits when the user explicitly changes the sort dropdown — it hasnt emitted anything yet. Without `startWith(asc')`, what would happen here?
javascript
combineLatest([
filters$,
sortOrder$.pipe(startWith('asc')),
]).subscribe(([filters, sort]) => applyQuery(filters, sort));ANothing different — combineLatest doesn't need every source to have emitted at least once
BcombineLatest would emit its very first combined value only once every source it's watching has emitted at least once — since sortOrder$ (a plain Subject) hasn't emitted anything yet, applyQuery would never run at all until the user happens to touch the sort dropdown, even if filters$ has already emitted plenty of values
CIt would throw a runtime error immediately
DcombineLatest would substitute undefined for sortOrder$ until it emits for the first time
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.