Comments (6)
This is causing issues for my app as well after updating target version to 30.
Caused by: java.lang.NullPointerException: onNext called with null. Null values are generally not allowed in 2.x operators and sources.
at io.reactivex.internal.operators.observable.ObservableCreate$CreateEmitter.onNext(ObservableCreate.java:62)
at com.f2prateek.rx.preferences2.RxSharedPreferences$1$1.onSharedPreferenceChanged(RxSharedPreferences.java:44)
at android.app.SharedPreferencesImpl$EditorImpl.notifyListeners(SharedPreferencesImpl.java:629)
at android.app.SharedPreferencesImpl$EditorImpl.lambda$notifyListeners$0$SharedPreferencesImpl$EditorImpl(SharedPreferencesImpl.java:643)
from rx-preferences.
The easy fix here would be to add a null
check here. However this would result in no notification being fired when preferences are cleared, which would be less than ideal.
I think we could also make it so that it emits the default value when this happens.
- emit a sentinel value in RxSharedPreferences when the key is null.
- handle this sentinel value in RealPreference to emit the default value.
from rx-preferences.
I wasn't prepared to update Robolectric to support API 30, so the supplied unit test doesn't run. But, otherwise the PR in #143 fixes this in a way suggested by @f2prateek.
from rx-preferences.
@f2prateek are you still working on this?
from rx-preferences.
I haven't worked on this - feel free to send a PR!
from rx-preferences.
@f2prateek @mseroczynski I'll try to get a PR for this with the recommend changes up sometime this week.
from rx-preferences.
Related Issues (20)
- asObservable() method do not emit values previously stored in SharedPreferences HOT 2
- Add MemoryPreference artifact? HOT 5
- Set Error Prone version for deterministic builds.
- transforming to single HOT 2
- Emissions from RxSharedPreferences.keyChanges HOT 2
- apply() is lossy HOT 7
- OutOfMemoryError while serialize gson.toJson(obj) HOT 4
- Expose an api for entirely non-null preferences HOT 5
- Question about deserializing null after migrating to 2.0.0
- Android X support HOT 5
- error: [Dagger/MissingBinding]
- StringAdapter returns null HOT 4
- unit testing with rxPreference
- RxJava3 HOT 1
- Support for EncryptedSharedPreference
- update changelog - mention AndroidX please
- Release a new version 2.0.2 HOT 7
- Build failure on master HOT 2
- Fork of f2prateek/rx-preferences HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rx-preferences.