Justin Yue
06/24/2021, 6:12 AMasync
would be my best bet since it returns a Deferred
that "represents a promise to provide a result later." However, I am not looking to wait for a result to be return. While I know I could probably return a dummy value (probably a boolean to represent the coroutine finished), are there any other alternatives to async
?louiscad
06/24/2021, 6:26 AMJustin Yue
06/24/2021, 6:37 AMsuspend fun extractTextFromFilePath(filePath: String): Boolean {
// code
}
class CameraViewModel(val context: Context): ViewModel() {
private var textBlocks = mutableMapOf<String, Array<Point?>>()
val textBlockString
get() = textBlocks.toString()
fun extractText(filePath: String): String {
viewModelScope.launch {
imageAnalyzer.extractTextFromFilePath(filePath)
}
Log.d(TAG, textBlockString)
return extractedText
}
}
textBlocksString
is no longer an empty stringtextBlocksString
, so how can I ensure that I run the other processing when `textBlocksString`has been properly updated by extractTextFromFilePath()