File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
mini-common/src/main/java/mini Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 1
1
buildscript {
2
2
ext {
3
3
kotlin_version = " 1.3.41"
4
- mini_version = " 4.0.2 "
4
+ mini_version = " 4.0.3 "
5
5
}
6
6
7
7
repositories {
Original file line number Diff line number Diff line change @@ -19,10 +19,14 @@ open class Resource<out T> @PublishedApi internal constructor(val value: Any?) {
19
19
}
20
20
21
21
@PublishedApi
22
- internal data class Failure (val exception : Throwable ? )
22
+ internal data class Failure (val exception : Throwable ? ) {
23
+ override fun toString (): String = " Failure($exception )"
24
+ }
23
25
24
26
@PublishedApi
25
- internal data class Loading <U >(val value : U ? = null )
27
+ internal data class Loading <U >(val value : U ? = null ) {
28
+ override fun toString (): String = " Loading($value )"
29
+ }
26
30
27
31
/* *
28
32
* Get the current value if successful, or null for other cases.
@@ -45,6 +49,10 @@ open class Resource<out T> @PublishedApi internal constructor(val value: Any?) {
45
49
fun <T > loading (value : T ? = null): Resource <T > = Resource (Loading (value))
46
50
fun <T > empty (): Resource <T > = Resource (Empty ())
47
51
}
52
+
53
+ override fun toString (): String {
54
+ return value.toString()
55
+ }
48
56
}
49
57
50
58
/* *
@@ -60,6 +68,16 @@ class Task(value: Any?) : Resource<Unit>(value) {
60
68
fun loading (): Task = Task (Loading <Unit >())
61
69
fun failure (exception : Throwable ? = null): Task = Task (Failure (exception))
62
70
}
71
+
72
+ override fun toString (): String {
73
+ return when {
74
+ isSuccess -> " Success"
75
+ isFailure -> " Failure"
76
+ isLoading -> " Loading"
77
+ isIdle -> " Idle"
78
+ else -> value.toString()
79
+ }
80
+ }
63
81
}
64
82
65
83
inline fun <T > Resource<T>.onSuccess (crossinline action : (data: T ) -> Unit ): Resource <T > {
You can’t perform that action at this time.
0 commit comments