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;
}
});
}
Hi. A parameterless create() has been already added to BehaviorSubject with v0.19.
what does it mean? how can I create Behavior subject without init value?
Just call BehaviorSubject.create()
I did, it creates anonymous subject
What do you mean by anonymous subject?
On Wed, Jun 7, 2017, 01:07 Viktor-Bredihin notifications@github.com wrote:
I did, it creates anonymous subject
—
You are receiving this because you commented.Reply to this email directly, view it on GitHub
https://github.com/ReactiveX/RxJava/issues/1364#issuecomment-306631529,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA7B3Dl4-rRFsJqf8xUKRT6PkmhzUBX1ks5sBc2hgaJpZM4CEZcf
.
I mean 'AnonymousSubject'. Have you seen the result of BehaviorSubject.create() ?
@Viktor-Bredihin I don't understand what you are talking about either. From the javadoc:

BehaviorSubject.create() returns BehaviorSubject<T> where T is the type parameter inferred from the usage or has to be specified like BehaviorSubject.<Integer>create() in some other cases.
it says that it creates behavior subject - yes, but when I create it and do console.log() it says 'AnonymousSubject'
What is your environment? A quick google search indicates AnonymousSubject is in RxJS, a JavaScript library. RxJava is a Java language library and as far as I remember there was never such AnonymousSubject.
here is my env https://github.com/AngularClass/angular-starter
new BehaviorSubject() returns as expected, but BehaviorSubject.create() returns AnonymousSubject
You have the wrong repository then. I suggest asking question on their site or StackOverflow about this.
@lexer , I know it was
long ago, but where you able to get rid of filter ? I have the exact same problem.

Most helpful comment
Hi. A parameterless create() has been already added to BehaviorSubject with v0.19.