diff --git a/app/src/main/java/keijumt/devandroid/viewmodel/AsyncViewModel.kt b/app/src/main/java/keijumt/devandroid/viewmodel/AsyncViewModel.kt index a7306a8..9a976b1 100644 --- a/app/src/main/java/keijumt/devandroid/viewmodel/AsyncViewModel.kt +++ b/app/src/main/java/keijumt/devandroid/viewmodel/AsyncViewModel.kt @@ -2,6 +2,8 @@ import android.os.AsyncTask import keijumt.devandroid.common.Task +import kotlinx.coroutines.experimental.async +import kotlinx.coroutines.experimental.launch import javax.inject.Inject class AsyncViewModel @Inject constructor() : BaseViewModel() { @@ -16,6 +18,14 @@ } fun coroutine() { + launch { + val result = calc(3).await() * calc(5).await() + println(result) + } + } + + fun calc(num: Int) = async { + return@async num * num } fun rx() {