kotlin.runCatching playground with retrofit

Overview

runCachingPlayground

In this repository I have tried some tricks to handle exceptions in a more kotlin way.

I have made http calls with Retrofit2 in different ways First wrapping the calls inside a runCaching block and then creating a custom CallAdapter to make Retrofit2 return a kotlin.Result

With the second approach the application can't crash from non handled exceptions

TIL

With my custom CallAdapter I can make a totally secure HTTP call like:

val successResult: List<Int> = Network.service.getRandomResult(
        fromNumber = 1,
        toNumber = 10,
        numbersOfResults = 3
    )
        .onFailure { println("Fail") }
        .onSuccess { println("Success") }
        .getOrNull()
You might also like...
Ejemplo de App Android con Kotlin, Jetpack Compose, Retrofit y consumo de la API REST de Pokémon
Ejemplo de App Android con Kotlin, Jetpack Compose, Retrofit y consumo de la API REST de Pokémon

Pokémon Jetpack Compose Ejemplo de App Android con Kotlin, Jetpack Compose, Retrofit y consumo de la API REST de Pokémon Jetpack Compose Retrofit Poké

Basic application that uses Retrofit, Moshi and Coil libraries to parse data from web API

DogAlbum_Api_CodeThrough Basic application that uses Retrofit, Moshi and Coil libraries to parse data from web API This folder contains the completed

Aplicativo simples de piadas do Chuck Norris fazendo o consumo de uma API com Retrofit.
Aplicativo simples de piadas do Chuck Norris fazendo o consumo de uma API com Retrofit.

Chuck-Norris-API-Android Aplicativo simples de piadas do Chuck Norris fazendo o consumo de uma API com Retrofit. A API NÃO FOI CRIADA POR MIM! Disponí

Android Github service with paging, hilt and retrofit

github-paging-hilt-retrofit This repository contains a simple app that implements Dagger-Hilt in MVVM architecture, Retrofit using Kotlin. The app has

MVVM ,Hilt DI ,LiveData ,Flow ,SharedFlow ,Room ,Retrofit ,Coroutine , Navigation Component ,DataStore ,DataBinding , ViewBinding, Coil
MVVM ,Hilt DI ,LiveData ,Flow ,SharedFlow ,Room ,Retrofit ,Coroutine , Navigation Component ,DataStore ,DataBinding , ViewBinding, Coil

RickMorty This is a simple app which has been implemented using Clean Architecture alongside MVVM design to run (online/offline) using : [ MVVM ,Hilt

Repo: Programming problems with solutions in Kotlin to help avid Kotlin learners to get a strong hold on Kotlin programming.

Kotlin_practice_problems Repo: Programming problems with solutions in Kotlin to help avid Kotlin learners to get a strong hold on Kotlin programming.

Mocking for Kotlin/Native and Kotlin Multiplatform using the Kotlin Symbol Processing API (KSP)

Mockative Mocking for Kotlin/Native and Kotlin Multiplatform using the Kotlin Symbol Processing API (KSP). Installation Mockative uses KSP to generate

Kotlin-oop - Repositório criado para ser utilizado pelo projeto de Kotlin OOP desenvolvido em Kotlin nas aulas feitas através da plataforma Alura.

Projeto React OOP Repositório criado para ser utilizado pelo projeto de Kotlin OOP desenvolvido em Kotlin nas aulas feitas através da plataforma Alura

Kotlin-koans - Kotlin Koans are a series of exercises to get you familiar with the Kotlin Syntax

kotlin-koans-edu Kotlin Koans are a series of exercises to get you familiar with

Owner
null
Playground UI Compose in Desktop Apps

caravan-kotlin-desktop-compose Project Learning Jetpack Compose on Desktop Aplication Request Data Retrofit Version Release This Is Latest Release $ve

Faisal Amir 15 Dec 8, 2022
Playground for Vault Integration

Vault Lab This is playground for spring-booter to test integrating with Vault the Hashi-Corp product. Secret-Engines that are available now: Transit :

Vandy Sodanheang 1 Apr 6, 2022
Playground server-client Android app using gRPC and protocol buffers

gRPC Playground The goal of this app is to connect to a server, exchange information using the gRPC protocol and lastly retrieve some mocked credentia

Thanos Psaridis 8 Sep 14, 2022
Modular Android architecture which showcase Kotlin, MVVM, Navigation, Hilt, Coroutines, Jetpack compose, Retrofit, Unit test and Kotlin Gradle DSL.

SampleCompose Modular Android architecture which showcase Kotlin, MVVM, Navigation, Hilt, Coroutines, Jetpack compose, Retrofit, Unit test and Kotlin

Mohammadali Rezaei 7 Nov 28, 2022
Shreyas Patil 2.2k Jan 4, 2023
Android News Reader app. Kotlin Coroutines, Retrofit and Realm

News Reader Android News Reader app Code that follows Packt Publishing Kotlin in Practice Video Course Example of Kotlin Coroutine usage, with Realm a

Marko Devcic 22 Oct 3, 2022
A clean architecture example. Using Kotlin Flow, Retrofit and Dagger Hilt, etc.

android-clean-architecture A clean architecture example. Using Kotlin Flow, Retrofit and Dagger Hilt, etc. Intro Architecture means the overall design

Prieyudha Akadita S. 69 Dec 21, 2022
🔥采用 Kotlin 语言编写,专为新手入门准备的项目。单Activity多Fragment,MVVM,ViewModel + LiveData + Retrofit + 协程, ViewBinding等等。拒绝过度设计和封装,项目结构清晰,代码简洁优雅。

前言 学习Kotlin有一段时间了,想写一个项目总结收获,就有了这个可能是东半球最简洁的玩安卓客户端,在此感谢玩Android 的开放API。 简介 采用 Kotlin 语言编写,专为新手入门准备的项目。单Activity多Fragment,MVVM,ViewModel + LiveData + R

zst 827 Dec 31, 2022
Android's MVVM Architecture in Kotlin ft. Retrofit

Android's MVVM Architecture in Kotlin ft. Retrofit This is an example to demonstrate MVVM Architecture in Kotlin with Retrofit in Android. This exampl

null 0 Dec 7, 2021
Belajar-Kotlin-RetrofitApp - Belajar Menggunakan Library Retrofit dalam Mengolah API

Belajar-Kotlin-RetrofitApp Belajar Menggunakan Library Retrofit dalam Mengolah A

Fernata Firdaus Purba 0 Feb 12, 2022