Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun <T : CoreViewState> MutableLiveData<T>.update(
- postUpdateEnabled: Boolean = true,
- block: T.() -> Unit
- ) {
- val data = value ?: run {
- Timber.w("You try to update NULL value of livedata")
- return
- }
- val hash = data.hashCode()
- block(data)
- val updatedHash = data.hashCode()
- if (postUpdateEnabled && hash != updatedHash) postValue(data)
- }
Advertisement
Add Comment
Please, Sign In to add comment