Daily iOS
Networking

Search debounce, cancellation, and out-of-order responses

You're asked to build, without third parties, a screen that calls a server search API on every keystroke in a search bar and refreshes the results list. How would you solve the problems a fast typist causes, using async/await?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

A request goes out per keystroke and requests that are no longer needed go to waste. On every input, cancel the previous Task, sleep briefly as a debounce, then request.

Share a question