64.6 Implementing the launchCoroutines Method
The final task before testing the app is to add the launchCoroutines() method which is called when the Button object is clicked. This method should be added to the MainActivity.kt file as follows:
.
.
import android.view.View
.
.
fun launchCoroutines(view: View) {
(1..count).forEach {
binding.statusText.text = "Started Coroutine ${it}"
coroutineScope.launch(Dispatchers.Main) {
binding.statusText.text = performTask(it).await()
}
}
...