Statefullivedata

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.
Alternatives To Statefullivedata
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Unpeek Livedata990
21 days ago16June 13, 20227Java
LiveData 数据倒灌:别问,问就是不可预期 - Perfect alternative to SingleLiveEvent, supporting multiple observers.
Liveevent294
2 years ago5June 26, 2021apache-2.0Kotlin
This library holds a class to handle single live events in Android MVVM architectural pattern. https://proandroiddev.com/livedata-with-single-events-2395dea972a8
Mvvm Databinding With Livedata Login58
3 years ago2apache-2.0Java
MVVM, DataBinding With LiveData - Login Example
Conductor Viewmodel33
4 years agoapache-2.0Java
Adds ViewModel and LiveData support to Conductor library
Food Ordering App Like Swiggy Uber Eats Mvvm And Room Database33
4 years ago2Java
Food ordering app using MVVM architecture patterns, Architecture Lifecycle components and Room database.
Archdata25
4 years agomitKotlin
LiveData types for Publishing and Replaying Data
Slush19
3 years ago4mitKotlin
A simple and easy adapter for RecyclerView. You don't have to make adapters and view holders anymore. Slush will help you.
Statefullivedata19
2 years ago1mitKotlin
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.
Observablecollections18
a year agoKotlin
Observable Collectons for Android Kotlin apps. Observes adds, deletes etc.
Reactivelivedata17
5 years agoapache-2.0Kotlin
An RxJava Extension for the LiveData observer introduced by Google.
Alternatives To Statefullivedata
Select To Compare


Alternative Project Comparisons
Readme

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.
Popular Observer Projects
Popular Livedata Projects
Popular Control Flow Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Kotlin
Coroutines
Observer
Retrofit2
Livedata