LiveEvent

by hadilq

hadilq / LiveEvent

https://proandroiddev.com/livedata-with-single-events-2395dea972a8

244 Stars 15 Forks Last release: over 1 year ago (v1.0.1) Apache License 2.0 39 Commits 3 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

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, not after configuration changes again. Note that event will only be sent to active observers, any observers that started observing after the emit won't be notified of the event.

Usage

This source has a sample app where you can find

LiveEventViewModel
in it, in which the
LiveEvent
class is used as follows. ```kotlin class LiveEventViewModel : ViewModel() { private val clickedState = LiveEvent() val state: LiveData = clickedState
fun clicked() {
    clickedState.value = ...
}

} ```

Download

Download via gradle

groovy
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.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.