I often need BehaviorSubject that don't have default value and should not spawn values until first value is supplied.
Currently as a workaround I initialize it with null and provide access to it after filter that ignores null value. Which looks ugly.
private BehaviorSubject<Location> locationUpdateSubject = BehaviorSubject.create((Location) null);
public Observable<Location> getLocationUpdates() {
return locationUpdateSubject.filter(new Func1<Location, Boolean>() {
@Override
public Boolean call(Location location) {
return location != null;
}
});
}
I often need BehaviorSubject that don't have default value and should not spawn values until first value is supplied.
Currently as a workaround I initialize it with null and provide access to it after filter that ignores null value. Which looks ugly.