# switchMap

An operator that switches to a new Observable for each value, cancelling the previous one.

## What does `switchMap` do?

`switchMap` turns each value into a new Observable (often an HTTP call) and cancels the previous one. Perfect for search boxes: only the latest search matters.

```typescript
results$ = this.searchText$.pipe(
  debounceTime(300),
  switchMap(text => this.http.get<Movie[]>(`/api/movies?q=${text}`)),
);
```

Level: Freelancer · [More Angular terms at this level](https://www.ask-codey.com/glossary?category=angular&level=4)

Updated: September 27, 2026

Source: https://www.ask-codey.com/glossary/switchmap
