Created
February 1, 2021 16:11
-
-
Save YuanLiou/df3011a5f92bf3d425558e360caad9d0 to your computer and use it in GitHub Desktop.
LiveEffect sending example #kotlin #LiveData #MVVM #MVI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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