Skip to content

Instantly share code, notes, and snippets.

@nayan-dhabarde
Created August 13, 2021 09:07
Show Gist options
  • Save nayan-dhabarde/f1ae5899a48b0860e04246ae68408c3b to your computer and use it in GitHub Desktop.
Save nayan-dhabarde/f1ae5899a48b0860e04246ae68408c3b to your computer and use it in GitHub Desktop.
Speak Coroutines with Deferred
class YourOldSyncLibrary {
val imageCompressor = ImageCompressor()
fun doSomethingSync(): Deferred<String> {
val
imageCompressor.compress(object: OnCompressListener {
override fun onCompress(filePath: String) {
}
override fun onError(exception: Exception) {
}
})
return
}
}
@nayan-dhabarde
Copy link
Author

Deferred executes simultaneously with another deferred when you call await on both

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment