본문 바로가기
Mobile#Mobile#Android#Kotlin조회 1

Kotlin Coroutine란?

정의

Kotlin의 비동기 프로그래밍 구조. suspend 함수로 콜백 헬 탈출.

Coroutine이란?

suspend fun fetch(): User = withContext(Dispatchers.IO) {
  api.getUser()
}
lifecycleScope.launch { val user = fetch() }

구성

  • suspend function
  • CoroutineScope
  • Dispatchers (IO, Main, Default)
  • Flow — 리액티브 스트림

🔗 함께 보면 좋은 용어

Mobile 전체 →