Skip to content

5.1. EventView

Gabriel Brasileiro edited this page Jun 13, 2020 · 4 revisions

EventView<Event> is a contract containing the method to get the event LiveData will be listened in your View.

BaseViewModel and EventViewModel implements this interface to can use the onEvent extension.

If you would like crate a customized EventViewModel all you need is implements this interface.

Example:

abstract class EventViewModel<E : Event>(
    private val event: SingleLiveEvent<E>
) : EventView<E>, ViewModel() {

    override fun getEvent(): LiveData<E> = event

    [...]
}

Sample Code

Clone this wiki locally