diff --git a/build.gradle.kts b/build.gradle.kts index d0be553f..23df6ec7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } group = "io.kamel" -version = "0.0.3" +version = "0.0.4" allprojects { repositories { @@ -30,7 +30,7 @@ publishing { create("maven") { groupId = "io.kamel" artifactId = "kamel-core" - version = "0.0.3" + version = "0.0.4" from(components["kotlin"]) } diff --git a/kamel-core/src/main/kotlin/io/kamel/core/LazyImage.kt b/kamel-core/src/main/kotlin/io/kamel/core/LazyImage.kt index e4d24370..c45f9858 100644 --- a/kamel-core/src/main/kotlin/io/kamel/core/LazyImage.kt +++ b/kamel-core/src/main/kotlin/io/kamel/core/LazyImage.kt @@ -32,15 +32,16 @@ public fun LazyImage( ) { when (resource) { is Resource.Loading -> if (onLoading != null) onLoading() - is Resource.Success -> Image( - resource.value, - contentDescription, - modifier, - alignment, - contentScale, - alpha, - colorFilter - ) + is Resource.Success -> + Image( + resource.value, + contentDescription, + modifier, + alignment, + contentScale, + alpha, + colorFilter + ) is Resource.Failure -> if (onFailure != null) onFailure(resource.exception) } } diff --git a/kamel-core/src/main/kotlin/io/kamel/core/Resource.kt b/kamel-core/src/main/kotlin/io/kamel/core/Resource.kt index c64867f7..fb647014 100644 --- a/kamel-core/src/main/kotlin/io/kamel/core/Resource.kt +++ b/kamel-core/src/main/kotlin/io/kamel/core/Resource.kt @@ -1,5 +1,7 @@ package io.kamel.core +import io.kamel.core.Resource.* + /** * A class represents an asynchronous resource loading. */ @@ -35,26 +37,26 @@ public sealed class Resource { * Returns true if the resource still in the loading state, false otherwise. */ public val Resource<*>.isLoading: Boolean - get() = this is Resource.Loading + get() = this is Loading /** * Returns true if the resource represents a successful outcome, false otherwise. */ public val Resource<*>.isSuccess: Boolean - get() = this is Resource.Success + get() = this is Success /** * Returns true if the resource represents a failure outcome, false otherwise. */ public val Resource<*>.isFailure: Boolean - get() = this is Resource.Failure + get() = this is Failure /** - * Returns [Resource.Success] with the [transform] function applied on the value if the resource represents success. - * or [Resource.Failure] with the original exception if the resource represents failure. + * Returns [Success] with the [transform] function applied on the value if the resource represents success. + * or [Failure] with the original exception if the resource represents failure. */ public inline fun Resource.map(transform: (T) -> R): Resource = when (this) { - is Resource.Loading -> Resource.Loading - is Resource.Success -> Resource.Success(transform(value)) - is Resource.Failure -> Resource.Failure(exception) + is Loading -> Loading + is Success -> Success(transform(value)) + is Failure -> Failure(exception) } \ No newline at end of file