This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Repository { | |
suspend fun getOrigami() : List<Entity> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlinx.serialization.Serializable | |
@Serializable | |
data class Entity( | |
val id: Int = 0, | |
val name: String = "", | |
val image: String = "", | |
val description: String = "" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GetOrigamiUseCase(private val repository: Repository) { | |
suspend fun invoke() = repository.getOrigami() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.ktor.client.* | |
import io.ktor.client.plugins.contentnegotiation.* | |
import io.ktor.serialization.kotlinx.json.* | |
import kotlinx.serialization.json.Json | |
fun createJson() = Json { isLenient = true; ignoreUnknownKeys = true } | |
fun createHttpClient( | |
json: Json | |
) = HttpClient { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.ktor.client.* | |
import io.ktor.client.call.* | |
import io.ktor.client.request.* | |
import org.koin.core.component.KoinComponent | |
interface RemoteDatasource { | |
suspend fun fetchOrigami(): List<Entity> | |
} | |
class RemoteDatasourceImpl( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RepositoryImpl( | |
private val remoteDatasource: RemoteDatasource | |
) : KoinComponent , Repository { | |
override suspend fun getOrigami(): List<Entity> = remoteDatasource.fetchOrigami() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.koin.core.Koin | |
import org.koin.core.context.startKoin | |
import org.koin.core.parameter.parametersOf | |
import org.koin.dsl.KoinAppDeclaration | |
import org.koin.dsl.module | |
import kotlin.reflect.KClass | |
fun initKoin(appDeclaration: KoinAppDeclaration = {}) = startKoin { | |
appDeclaration() | |
modules(commonModule, platformModule()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val ktorVersion = "2.0.2" | |
val koinVersion = "3.2.0" | |
val serializationVersion = "1.3.2" | |
val commonMain by getting { | |
dependencies { | |
// Ktor | |
implementation("io.ktor:ktor-client-core:$ktorVersion") | |
implementation("io.ktor:ktor-client-serialization:$ktorVersion") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugins { | |
kotlin("multiplatform") | |
id("com.android.library") | |
kotlin("plugin.serialization") version "1.5.0" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val coroutinesVersion = "1.6.1" | |
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") | |
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion") | |
val koinVersion = "3.2.0" | |
implementation("io.insert-koin:koin-android:$koinVersion") | |
val composeVersion = "1.1.1" | |
implementation("androidx.compose.ui:ui:$composeVersion") | |
implementation("androidx.compose.material:material:$composeVersion") |
OlderNewer