rx-java

How to set default value in BehaviourSubject

馋奶兔 提交于 2020-08-25 07:43:43
问题 Probably a noob question. How do I set a default value to a BehaviourSubject. I have an enum with 2 different values enum class WidgetState { HIDDEN, VISIBLE } And a behaviour subject which emits the states val widgetStateEmitter: BehaviorSubject<WidgetState> = BehaviorSubject.create() My emitter starts emitting when the view logic is written. However it's HIDDEN by default. How do I set the default value as WidgetState.HIDDEN to my emitter widgetStateEmitter ? 回答1: There's a static

Observing SharedPreferences Data

孤者浪人 提交于 2020-08-24 01:19:25
问题 I am trying to observe data changes in shared preferences. I found this similar question answered by @SimplyProgrammerand followed the steps that he directed and at the end of the day my observer was still not working. Then I decided to seek some assistance to better understand why. this is my implementation I started by implementing the abstract live data SharedPreferences preference; String key; T defValue; public SharedPrefferenceLiveData(SharedPreferences preference,String key,T defValue)

Observing SharedPreferences Data

霸气de小男生 提交于 2020-08-24 01:17:11
问题 I am trying to observe data changes in shared preferences. I found this similar question answered by @SimplyProgrammerand followed the steps that he directed and at the end of the day my observer was still not working. Then I decided to seek some assistance to better understand why. this is my implementation I started by implementing the abstract live data SharedPreferences preference; String key; T defValue; public SharedPrefferenceLiveData(SharedPreferences preference,String key,T defValue)