Skip to content

dommy1985/LiveEvent

 
 

Repository files navigation

Build Status Maven Central

Live Event

This library holds a class to handle single live events in Android MVVM architectural pattern. This class is extended form LiveData class, from androidx.lifecycle:lifecycle-extensions library, to propagate the data as an event, which means it emits data just once.

Usage

This source has a sample app where you can find LiveEventViewModel in it, in which the LiveEvent class is used as follows.

class LiveEventViewModel : ViewModel() {
    private val clickedState = LiveEvent<String>()
    val state: LiveData<String> = clickedState

    fun clicked() {
        clickedState.value = ...
    }
}

Download

Download via gradle

implementation "com.github.hadilq.liveevent:liveevent:$libVersion"

where the libVersion is Maven Central.

Contribution

Just create your branch from the master branch, change it, write additional tests, satisfy all tests, create your pull request, thank you, you're awesome.