Skip to content

Instantly share code, notes, and snippets.

@YuanLiou
Created February 1, 2021 16:11
Show Gist options
  • Save YuanLiou/df3011a5f92bf3d425558e360caad9d0 to your computer and use it in GitHub Desktop.
Save YuanLiou/df3011a5f92bf3d425558e360caad9d0 to your computer and use it in GitHub Desktop.
LiveEffect sending example #kotlin #LiveData #MVVM #MVI
class Event<out T>(private val content: T) {
var hasBeenHandled = false
private set
fun getContentIfNotHandled(): T? {
if (hasBeenHandled) {
return null
} else {
hasBeenHandled = true
return content
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment