Question presented to candidate: "A dashboard needs the user and their permissions before it renders, a product list re-filters whenever the search text or the category changes, and a Save button sends the current filters. Which RxJS combination operators would you use, and how do forkJoin, zip, combineLatest and withLatestFrom differ?"
What a strong answer should cover:
- forkJoin waits for every source to complete, then emits once with each source's last value: the RxJS
Promise.all, ideal for parallel HTTP calls. If any source completes empty it emits nothing; if any errors, it errors. - zip pairs values by index (1st with 1st, 2nd with 2nd) and buffers the faster source.
- combineLatest waits until each source has emitted once, then emits the latest of all on every emission from any source: derived state from several inputs.
- withLatestFrom is an operator: only the source triggers an emission; the other streams are sampled, and source values that arrive before the others have a value are dropped.
- Practical differences: completion behaviour, the object/array forms (
forkJoin({ a, b })), deprecated rest-argument signatures, and thatcomputed()often replacescombineLatestfor signal state.
Clarifying questions expected:
- "Do the sources complete (HTTP calls) or are they long-lived (form values, store selectors)?"
- "Should every source be able to trigger an update, or only one of them?"
Code / implementation expected: Yes β a timeline or small component that shows when each operator emits for the same inputs.