Daily iOS
iOS system design

BLE command serializing handler

Design the command handler for an app that talks to a wearable over BLE. Constraints: only one command can be in flight at a time, and the next command has to wait until the previous one gets a response or times out. Several screens send commands concurrently, and responses arrive asynchronously through CoreBluetooth delegate callbacks. Describe the type structure of this handler.

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 CommandExecutor actor holds a FIFO queue and runs commands one at a time as an async function. Whichever comes first, the timeout Task or the response, completes the current command and moves to the next, and on cancellation or disconnect the queued commands fail immediately.

Share a question