
Facilitates handling of network operations by providing utilities for either pattern, pretty printing logs, and resource mapping. Documentation and integration details accessible online.
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<ErrorDTO, DogDTO> = client.get("dog").body()
response.fold(
failure = { ... },
success = { ... },
)Check all available functions in the
NetworkEither class.
Check the tests for more examples.
val retrofit =
Retrofit
.Builder()
.baseUrl("org.example.com")
.addCallAdapterFactory(NetworkEitherCallAdapterFactory())
.build()
interface DogService {
@GET("dog")
suspend fun getDog(): NetworkEither<ErrorDTO, DogDTO>
}
val service: DogService = retrofit.create()
val response: NetworkEither<ErrorDTO, DogDTO> = service.getDog()
response.fold(
failure = { ... },
success = { ... },
)Check the tests for more examples.
All docs are available on the network-either-kmp website
implementation("com.javiersc.network:network-either:$version")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<ErrorDTO, DogDTO> = client.get("dog").body()
response.fold(
failure = { ... },
success = { ... },
)Check all available functions in the
NetworkEither class.
Check the tests for more examples.
val retrofit =
Retrofit
.Builder()
.baseUrl("org.example.com")
.addCallAdapterFactory(NetworkEitherCallAdapterFactory())
.build()
interface DogService {
@GET("dog")
suspend fun getDog(): NetworkEither<ErrorDTO, DogDTO>
}
val service: DogService = retrofit.create()
val response: NetworkEither<ErrorDTO, DogDTO> = service.getDog()
response.fold(
failure = { ... },
success = { ... },
)Check the tests for more examples.
All docs are available on the network-either-kmp website
implementation("com.javiersc.network:network-either:$version")