switchMap
switchMap is an operator used in reactive programming, notably in RxJS. It maps each value from a source observable into an inner observable and subscribes to the most recent inner observable, unsubscribing from any previously active inner observer.
Mechanism: for every emission from the source, it applies a projection function to produce an inner observable.
When to use: switchMap is especially useful when only the latest result matters, such as type-ahead search,
Example (conceptual): source$.pipe(switchMap(value => httpRequest(value))). This setup triggers a new HTTP request for each new value but