Pablo Costa
12/02/2018, 12:14 PMStuffRepo.kt
stuffDS.loadStuff (object: LoadStuffCallbacks {
override fun onSuccess(stuff : Stuff) {
// stuff ready
}
override fun onError() {
// error handling
}
})
StuffDS.kt
fun loadStuff(callbacks : LoadStuffCallbacks) {
val stuff = dao.loadStuff()
if (stuff != null) callbacks.onSuccess(stuff)
else callbacks.onError()
}
interface LoadStuffCallbacks {
fun onSuccess(stuff : Stuff)
fun onError()
}
I'm trying to replicate exactly same behaviour eliminating completely the callbacks. Is it possible to do it? What's the cleanest way of doing this?
Thanks a lot!dave08
12/02/2018, 12:20 PMPablo Costa
12/02/2018, 12:41 PMdave08
12/02/2018, 12:44 PMsuspend fun
everywhere without any of those callbacks... you should really read the coroutine guide and understand the basics... also Roman put out a few articles in #feed recently... (look back in the history of that channel).Pablo Costa
12/02/2018, 1:18 PM