DevPrep

All topics › Real interview tasks

Implement a debouncer with DispatchWorkItem

Middle PRO

Task

A debouncer delays an action by delay and cancels the previous one if a new call arrives earlier. The classic: search-as-you-type — the request goes out only after a pause in typing. Implement it with DispatchWorkItem, then show the modern version.

The rest of this answer, with code and interview follow-ups, is in the DevPrep app.

Read the full answer in DevPrep

Practice this before your interview

DevPrep turns these answers into one-minute challenges: what does this code print, find the bug, mock interviews. One challenge a day.

Get DevPrep on the App Store