Handle null in RxJava2
问题 There is a need where I want load data from local or remote. If local data fetched, remote data won't be fetched. As local data can be empty (i.e. null) , I have to handle null situation in RxJava2, so I do it with help of Optional util in java-8. Here is code. String data; Observable<Optional<String>> loadCacheData() { return Observable.create(emitter -> { emitter.onNext(Optional.ofNullable(null)); emitter.onComplete(); }); } Observable<Optional<String>> loadRemoteData() { Observable