f2prateek / rx-preferences

Reactive SharedPreferences for Android
http://f2prateek.com/2015/10/05/rx-preferences/
Apache License 2.0
1.54k stars 132 forks source link

transforming to single #117

Closed seyedjafariy closed 6 years ago

seyedjafariy commented 6 years ago

Hi and thank you for your great effort on this library. there is only one thing I'd like to ask: when i use .asObservable() to get the result as a stream so I can transform it later in the chain (using concatMap or singleOrError or even toList) the chain won't work and .subscribe() won't get called. as far as I could understand the reason for this problem is that you are using OnSharedPreferenceChangeListener to get changes not the value therefore by not calling .complete() in the onCreate of your observable. we won't be able to transform the chain to any form of Single (since it needs the sourceObservable to call onComplete to carry on)

is there any way we can do the transformation without breaking the chain?

JakeWharton commented 6 years ago

Use firstOrError()

On Sun, Apr 29, 2018, 8:15 AM worldsnas notifications@github.com wrote:

Hi and thank you for your great effort on this library. there is only one thing I'd like to ask: when i use .asObservable() to get the result as a stream so I can transform it later in the chain (using concatMap or singleOrError or even toList) the chain won't work and .subscribe() won't get called. as far as I could understand the reason for this problem is that you are using OnSharedPreferenceChangeListener to get changes not the value therefore by not calling .complete() in the onCreate of your observable. we won't be able to transform the chain to any form of Single (since it needs the sourceObservable to call onComplete to carry on)

is there any way we can do the transformation without breaking the chain?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/f2prateek/rx-preferences/issues/117, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEZ57pMbJlpetaq-co82ob3uMHxtvks5tta7FgaJpZM4Trxyy .

seyedjafariy commented 6 years ago

oh, that was easy. thank you so much. save the day