Skip to content
RED SAGSkills
easyMobile App Developer interview question

How do you run slow work like network calls or database reads in a mobile app without freezing the UI?

What the interviewer wants to hear

  • The main thread draws the UI and handles touches, so it must not be blocked
  • Use the platform async tools: Kotlin coroutines, Swift async/await, Dart Futures or JS promises
  • Move blocking or heavy work to a background dispatcher, actor or isolate
  • Update the UI back on the main thread
  • Tie work to a lifecycle scope so it is cancelled when the screen goes away

Model answer

The main thread draws every frame and handles touches, so anything slow there causes jank or an ANR on Android. I use the async tools of the platform. In Kotlin I launch coroutines in viewModelScope and wrap blocking I/O in withContext(Dispatchers.IO). In Swift I use async/await, keep UI code on the main actor and let URLSession suspend instead of blocking. In Flutter, network calls are Futures, and heavy CPU work like parsing huge JSON goes to another isolate with compute or Isolate.run. In React Native I keep the JS thread free of long loops. I also tie the work to a lifecycle scope, so if the user leaves the screen the work is cancelled and nobody updates a dead view. Finally, I show loading and error states so the user always knows what is happening.

Can you answer it under time pressure?

Take a timed easy round and get scored on every answer.

Start mock interview

More easy Mobile App Developer questions