Created
May 5, 2020 23:12
-
-
Save ekoo/a1ea2ba169e325a4443eaeaa6f56573e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun jagaKonter() = viewModelScope.launch { | |
val listrik = async { beliListrik() } | |
val pulsa = async { beliPulsa() } | |
Log.d("example", "Semua Transaksi Selesai, Total Pendapatan : Rp. ${listrik.await()+pulsa.await()}") | |
} | |
suspend fun beliListrik(): Int{ | |
Log.d("example", "Melayani Pelanggan Pertama") | |
delay(7000L) | |
val price = 52000 | |
Log.d("example", "Transaksi Pertama Selesai") | |
return price | |
} | |
suspend fun beliPulsa(): Int{ | |
Log.d("example", "Melayani Pelanggan Kedua") | |
delay(5000L) | |
val price = 21000 | |
Log.d("example", "Transaksi Kedua Selesai") | |
return price | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment