You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have some minor improve suggestion - Result class is currently implemented in Java style and not getting benefits of the Kotlin compiler.
Having Result class implemented as
sealed class Result<out T> {
class loading<T> : Result<T>()
data class error<T>(val message: String) : Result<T>()
data class success<T>(val data: T) : Result<T>()
}
you can avoid excess nullability checks(!!) and possible exceptions in places like
if (responseStatus.status == SUCCESS) {
saveCallResult(responseStatus.data!!)
} else if (responseStatus.status == ERROR) {
emit(Result.error<T>(responseStatus.message!!))
emitSource(source)
}
and have it in more Kotlin way
if (responseStatus is Result.success) {
saveCallResult(responseStatus.data)
} else if (responseStatus is Result.error) {
emit(Result.error<T>(responseStatus.message))
emitSource(source)
}
Hope you find it useful :)
The text was updated successfully, but these errors were encountered:
Great project, thanks for sharing!
I have some minor improve suggestion - Result class is currently implemented in Java style and not getting benefits of the Kotlin compiler.
Having Result class implemented as
you can avoid excess nullability checks(!!) and possible exceptions in places like
and have it in more Kotlin way
Hope you find it useful :)
The text was updated successfully, but these errors were encountered: