The main difference between PublishSubject
and BehaviorSubject
is that the latter one remembers the last emitted item. Because of that BehaviorSubject
is really useful when you want to emit states
.
Why they make project field a BehaviorSubject and not PublishSubject ?
Probably because they want to be able to retrieve the last emitted project with this method:
@Override public @NonNull Observable<Project> project() {
return this.project;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…