All Projects → climacell → StatefulLiveData

climacell / StatefulLiveData

Licence: MIT license
StatefulLiveData is a lean, yet powerful tool that harnesses the capabilities of LiveData and enhances them, enabling the observer to distinguish between different states the data can be in, such as Success, Loading and Error.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to StatefulLiveData

Fountain
Android Kotlin paged endpoints made easy
Stars: ✭ 175 (+872.22%)
Mutual labels:  coroutines, retrofit2, livedata
Superhero-App
🦸🏻‍♂️🦹🏻‍♀️Superhero app built with Kotlin, ViewModel, LiveData, ViewBinding, Room, and Hilt
Stars: ✭ 27 (+50%)
Mutual labels:  coroutines, retrofit2, livedata
android-clean-architecture
🚀🚀🚀 The boilerplate for Android using Kotlin & Clean architecture.
Stars: ✭ 21 (+16.67%)
Mutual labels:  coroutines, retrofit, livedata
Foodium
It simply loads Posts data from API and stores it in persistence storage (i.e. SQLite Database). Posts will be always loaded from local database. Remote data (from API) and Local data is always synchronized.
Stars: ✭ 1,940 (+10677.78%)
Mutual labels:  coroutines, retrofit2, livedata
Dagger-Hilt-MVVM
Sample app that demonstrates the usage of Dagger Hilt with Kotlin & MVVM
Stars: ✭ 62 (+244.44%)
Mutual labels:  coroutines, retrofit2, livedata
Sunset-hadith
Islamic app written with Kotlin, using KTOR + coroutines + flow + MVVM + Android Jetpack + Navigation component. Old version using RxJava + Retrofit + OKHttp
Stars: ✭ 26 (+44.44%)
Mutual labels:  coroutines, retrofit2, livedata
Android Kotlin Mvi Cleanarchitecture
Android + Kotlin + Modularization + Gradle Depedency managment + Gradle written in Kotlin DSL + Custom Gradle Plugin + MVVM + MVI + Clean Architecture + Repository Pattern + Coroutines + Flows + Koin + Retrofit2 + ROOM + Kotlin-Android-Extension + KtLints
Stars: ✭ 187 (+938.89%)
Mutual labels:  coroutines, retrofit, retrofit2
eyepetizer kotlin
一款仿开眼短视频App,分别采用MVP、MVVM两种模式实现。一、组件化 + Kotlin + MVP + RxJava + Retrofit + OkHttp 二、组件化 + Kotlin + MVVM + LiveData + DataBinding + Coroutines + RxJava + Retrofit + OkHttp
Stars: ✭ 83 (+361.11%)
Mutual labels:  coroutines, retrofit2, livedata
DirectCurrencyConverter
Currency Converter App for Android showing usage of Flow, Live Data, Coroutines, Hilt - (Clean Architecture)
Stars: ✭ 40 (+122.22%)
Mutual labels:  coroutines, retrofit2, livedata
WanAndroidJetpack
🔥 WanAndroid 客户端,Kotlin + MVVM + Jetpack + Retrofit + Glide。基于 MVVM 架构,用 Jetpack 实现,网络采用 Kotlin 的协程和 Retrofit 配合使用!精美的 UI,便捷突出的功能实现,欢迎下载体验!
Stars: ✭ 124 (+588.89%)
Mutual labels:  coroutines, retrofit, livedata
Ktarmor Mvvm
👻 Android快速开发框架, KtArmor 寓意着 为Android 赋予战斗装甲, 方便开发者快速进行Android 开发。
Stars: ✭ 148 (+722.22%)
Mutual labels:  coroutines, retrofit, livedata
Kotlin Coroutines Retrofit
Kotlin Coroutines await() extension for Retrofit Call
Stars: ✭ 812 (+4411.11%)
Mutual labels:  coroutines, retrofit, retrofit2
KotlinEverywhere
This application created for Kotlin Everywhere series as a codelab. It will show step by step Kotlin and Android Jetpack Components fundamentals. 🚀🚀
Stars: ✭ 52 (+188.89%)
Mutual labels:  coroutines, retrofit, livedata
Gallerit
A sample Android gallery to search images posted on Reddit built using modern Android development tools (Architecture Components, MVVM, Coroutines, Flow, Navigation, Retrofit, Room, Koin)
Stars: ✭ 153 (+750%)
Mutual labels:  coroutines, retrofit2, livedata
ComposeMovie
Movie app that built with Jetpack Compose
Stars: ✭ 96 (+433.33%)
Mutual labels:  coroutines, retrofit, livedata
Kotlinjetpackinaction
🔥🔥 Kotlin Jetpack zero to hero. 新手到高手
Stars: ✭ 264 (+1366.67%)
Mutual labels:  coroutines, retrofit2, livedata
Sample Code Movies
This repository contains sample code. Its purpose being, to quickly demonstrate Android and software development in general, clean code, best practices, testing and all those other must know goodies.
Stars: ✭ 81 (+350%)
Mutual labels:  coroutines, retrofit, livedata
Coolweather
Weather App that uses Android best practices. Android Jetpack, clean architecture. Written in Kotlin
Stars: ✭ 154 (+755.56%)
Mutual labels:  coroutines, retrofit2
Topcorn
A minimalistic movie listing app to browse IMDB's top 250 movies, built to demonstrate MVVM with latest hot-trending Android development tools.
Stars: ✭ 131 (+627.78%)
Mutual labels:  coroutines, retrofit
Android Clean Arch Coroutines Koin
Implemented by Clean Architecture, MVVM, Koin, Coroutines, Moshi, Mockk, LiveData & DataBinding
Stars: ✭ 173 (+861.11%)
Mutual labels:  coroutines, livedata

StatefulLiveData

Release API

StatefulLiveData is a lean, yet powerful tool that harnesses the capabilities of LiveData and enhances them, enabling the observer to distinguish between different states the data can be in, such as Success, Loading and Error.

StatefulLiveData is open-ended, which gives you possibility to create more types of StatefulData, as well as extensions and functionality.

Quick start guide

Setup

Adding the dependency to the project using gradle or maven.

Gradle setup

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.climacell.statefullivedata:core:1.0.0'
}

Maven setup

<!-- <repositories> section of pom.xml -->
<repository>
    <id>jitpack.io</id>
   <url>https://jitpack.io</url>
</repository>

<!-- <dependencies> section of pom.xml -->
<dependency>
    <groupId>com.github.climacell.statefullivedata</groupId>
    <artifactId>core</artifactId>
    <version>1.0.0</version>
</dependency>

Usage

Create a StatefulLiveData object:

val myStatefulLiveData: MutableStatefulLiveData<String> = MutableStatefulLiveData<String>()

Observe:

myStatefulLiveData.observe(lifecycleOwner, Observer { statefulData: StatefulData<String> ->  
	when (statefulData) {  
		is StatefulData.Success -> {  
			showMyData(statefulData.data)  
		}
		is StatefulData.Loading -> {  
			showProgressBar()  
		}
		is StatefulData.Error -> {  
			showError(statefulData.throwable)  
		} 
	}
})

Update states:

Put success state

myStatefulLiveData.putData("My data String.") 

Put loading state

myStatefulLiveData.putLoading()

Put error state

myStatefulLiveData.putError(IllegalArgumentException())

Thats it! You are ready to go! =)

For more awesome capabilities and other super powers check out the other modules that accompany the core module. Also make sure to look at the kdoc in the library.

Documentation

Coming soon.

Modules

There are 4 modules comprising StatefulLiveData:

  • Core - The essential components of the StatefulLiveData framework.
  • Coroutines - Additional functionalities to further enhance StatefulLiveData with coroutines.
  • Google-Tasks - Provides easy conversions from Tasks to StatefulLiveData.
  • Retrofit - A Retrofit adapter to convert calls to StatefulLiveData.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].