Skip to content

Commit 3f314e2

Browse files
authored
Update RepositoryExtensions.kt
1 parent 679a341 commit 3f314e2

File tree

1 file changed

+0
-24
lines changed

1 file changed

+0
-24
lines changed

app/src/main/java/com/monstarlab/arch/extensions/RepositoryExtensions.kt

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,3 @@ inline fun <T, R> Response<T>.mapSuccess(
2828
throw toError()
2929
}
3030
}
31-
32-
sealed class RepositoryResult<out T> {
33-
data class Success<T>(val value: T): RepositoryResult<T>()
34-
data class Error(val error: ErrorModel): RepositoryResult<Nothing>()
35-
}
36-
37-
inline fun <T> RepositoryResult<T>.onSuccess(block: (T) -> Unit): RepositoryResult<T> {
38-
if(this is RepositoryResult.Success) block.invoke(value)
39-
return this
40-
}
41-
42-
inline fun <T> RepositoryResult<T>.onError(block: (ErrorModel) -> Unit): RepositoryResult<T> {
43-
if(this is RepositoryResult.Error) block.invoke(error)
44-
return this
45-
}
46-
47-
fun <T> RepositoryResult<T>.isError(): Boolean {
48-
return this is RepositoryResult.Error
49-
}
50-
51-
val <T> RepositoryResult<T>.errorOrNull: ErrorModel?
52-
get() {
53-
return if(this is RepositoryResult.Error) error else null
54-
}

0 commit comments

Comments
 (0)