https://github.com/javiersegoviacordoba/network-either-kmp
https://github.com/javiersegoviacordoba/network-either-kmp
arrow arrow-kt functional-programming hacktoberfest kotlin kotlin-multiplatform ktor ktor-client multiplatform multiplatform-kotlin-library retrofit retrofit2
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/javiersegoviacordoba/network-either-kmp
- Owner: JavierSegoviaCordoba
- Created: 2020-12-19T16:06:03.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-06-14T21:24:02.000Z (6 months ago)
- Last Synced: 2025-06-14T22:23:32.652Z (6 months ago)
- Topics: arrow, arrow-kt, functional-programming, hacktoberfest, kotlin, kotlin-multiplatform, ktor, ktor-client, multiplatform, multiplatform-kotlin-library, retrofit, retrofit2
- Language: Kotlin
- Homepage: https://network-either-kmp.javiersc.com
- Size: 10.1 MB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README

[](https://repo1.maven.org/maven2/com/javiersc/network/network-either/)
[](https://oss.sonatype.org/content/repositories/snapshots/com/javiersc/network/network-either/)
[](https://github.com/JavierSegoviaCordoba/network-either-kmp/tree/main)
[](https://sonarcloud.io/dashboard?id=com.javiersc.network:network-either)
[](https://sonarcloud.io/dashboard?id=com.javiersc.network:network-either)
[](https://sonarcloud.io/dashboard?id=com.javiersc.network:network-either)
# Network Either
## Ktor
### Usage
```kotlin
val client: HttpClient = HttpClient(MockEngine) {
install(NetworkEitherPlugin)
install(ContentNegotiation) {
json(defaultJson)
}
}
@Serializable
data class DogDTO(val id: Int, val name: String, val age: Int)
@Serializable
data class ErrorDTO(val message: String)
val response: NetworkEither = client.get("dog").body()
response.fold(
failure = { ... },
success = { ... },
)
```
Check all available functions in the [
`NetworkEither` class](subprojects/network-either/common/main/kotlin/com/javiersc/network/either/NetworkEither.kt).
Check [the tests](subprojects/network-either/common/test/kotlin/com/javiersc/network/either/KtorTest.kt)
for more examples.
## Retrofit
### Usage
```kotlin
val retrofit =
Retrofit
.Builder()
.baseUrl("org.example.com")
.addCallAdapterFactory(NetworkEitherCallAdapterFactory())
.build()
interface DogService {
@GET("dog")
suspend fun getDog(): NetworkEither
}
val service: DogService = retrofit.create()
val response: NetworkEither = service.getDog()
response.fold(
failure = { ... },
success = { ... },
)
```
Check [the tests](subprojects/network-either/jvm/test/kotlin/com/javiersc/network/either/RetrofitTest.kt)
for more examples.
## Docs
All docs are available on the [`network-either-kmp` website](https://network-either-kmp.javiersc.com)
## Download from MavenCentral
- NetworkEither, pretty printing logger and ResourceEither mappers
```kotlin
implementation("com.javiersc.network:network-either:$version")
```