KunMinX / UnPeek-LiveData

LiveData 数据倒灌:别问,问就是不可预期 - Perfect alternative to SingleLiveEvent, supporting multiple observers.
1.2k stars 120 forks source link

ProtectedUnPeekLiveData 中的 AtomicInteger 可以替换为 Int吧? #32

Closed Aarontaken closed 2 years ago

Aarontaken commented 2 years ago

看了下 currentVersion 使用的地方都是限制了主线程的,直接用 Int 就行,即和 LiveData 中的 version 一致。

KunMinX commented 2 years ago

感谢提醒,应该是忘改。 atomicInteger 是 v7.0 在 postValue 中使用而为, 目前操作 atomicInteger 之处皆已置于主线程环节。 不过根据其微小的性能开销,暂且还是保留该设计,以免后续如添加子线程设计时埋下不可预期错误。