package com.gh.gamecenter.livedata

//link:https://medium.com/google-developers/livedata-with-snackbar-navigation-and-other-events-the-singleliveevent-case-ac2622673150
/**
 *  Used as a wrapper for data that is exposed via a LiveData that represents an event.
 */
class Event<out T>(
    private val content: T
) {

    private var hasBeenHandled = false

    fun getContentWithHandled(): T? =
        if (hasBeenHandled) {
            null
        } else {
            hasBeenHandled = true
            content
        }

    fun peekContent(): T = content
}