Overview¶
🥪 Sandwich is an adaptable and lightweight sealed API library designed for handling API responses and exceptions in Android for Retrofit, and Kotlin Multiplatform for Ktor, and Ktorfit.
Why Sandwich?¶
Sandwich was conceived to streamline the creation of standardized interfaces to model responses from Retrofit, Ktor, and whatever. This library empowers you to handle body data, errors, and exceptional cases more succinctly, utilizing functional operators within a multi-layer architecture. With Sandwich, the need to create wrapper classes like Resource or Result is eliminated, allowing you to concentrate on your core business logic. Sandwich boasts features such as global response handling, Mapper, Operator, and exceptional compatibility, including ApiResponse With Coroutines.
Download¶
Sandwich has achieved an impressive milestone, being downloaded in over 300,000 Android projects worldwide!
Gradle¶
Add the dependency below into your module's build.gradle
file:
dependencies {
implementation "com.github.skydoves:sandwich:$version"
}
dependencies {
implementation("com.github.skydoves:sandwich:$version")
}
For Kotlin Multiplatform, add the dependency below to your module's build.gradle.kts
file:
sourceSets {
val commonMain by getting {
dependencies {
implementation("com.github.skydoves:sandwich:$version")
}
}
}
References¶
You can delve deeper into the art of modeling Retrofit responses through the following resources:
- [YouTube]: Modeling Retrofit responses with sealed classes and coroutines with Jaewoong Eum
- Modeling Retrofit Responses With Sealed Classes and Coroutines
- Handling success data and error callback responses from a network for Android projects using Sandwich
Use Cases¶
You can also check out nice use cases of this library in the repositories below:
- Pokedex: 🗡️ Android Pokedex using Hilt, Motion, Coroutines, Flow, Jetpack (Room, ViewModel, LiveData) based on MVVM architecture.
- ChatGPT Android: 📲 ChatGPT Android demonstrates OpenAI's ChatGPT on Android with Stream Chat SDK for Compose.
- DisneyMotions: 🦁 A Disney app using transformation motions based on MVVM (ViewModel, Coroutines, LiveData, Room, Repository, Koin) architecture.
- MarvelHeroes: ❤️ A sample Marvel heroes application based on MVVM (ViewModel, Coroutines, LiveData, Room, Repository, Koin) architecture.
- Neko: Free, open source, unofficial MangaDex reader for Android.
- TheMovies2: 🎬 A demo project using The Movie DB based on Kotlin MVVM architecture and material design & animations.