Answers for "kotlin coroutines launch"

3

coroutines kotlin android dependency

dependencies {
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7'
}
Posted by: Guest on June-15-2020
2

kotlin coroutines dependency

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1'
Posted by: Guest on May-31-2021
2

kotlin coroutines

import kotlinx.coroutines.*
// Asynchronous execution
fun main() {
  GlobalScope.launch { 	// creates a new coroutine and continues
    doWorld()			// suspending function
  }
  println("World !") 	// execution continues even while coroutine waits
  runBlocking { 		// block main thread for 4 s (waits for 1rst coroutine)
  	delay(4000L) 		
  }
}
suspend fun doWorld() {
  delay(2000L) 		// non-blocking delay for 2000 milliseconds
  println("Hello")	// printed after "World !"
}
Posted by: Guest on April-21-2021
0

kotlin coroutine invoke completion

fun getData(){
	uiScope.launch{
    	dataRepository.getData()
    }.invokeOnCompletion{
    	Log.d("Tag","Called after completion")
    }
}
Posted by: Guest on July-14-2020
-2

kotlin coroutines dependency

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8'
Posted by: Guest on June-18-2021

Browse Popular Code Answers by Language