Skip to content

dqh147258/SafeLiveData

Repository files navigation

A thread safe LiveData

Features

  • you can use the LiveData in background thread safely
  • you can use the LiveData out of ViewModel without considering memory leak(except observeForever)

How to use

dependencies

	allprojects {
		repositories {
			//...
			maven { url 'https://www.jitpack.io' }
		}
	}
	dependencies {
            def lastSafeLiveDataVersion = "1.1.1" //replace lastSafeLiveDataVersion
            implementation "com.github.dqh147258:SafeLiveData:$lastSafeLiveDataVersion"
	}

use it by

    val infoLiveData = SafeLiveData<Int>()

or

    val yourLiveData = MediatorLiveData<Int>()
    val infoLiveData = SafeLiveData<Int>(yourLiveData)

About

A LiveData can safely used without ViewModel

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors