9

I would like to observe my BehaviourSubject. In RxJava 1 I was calling asObservable(), which is now gone.

I found publish() but it returns connectable, which I don't want to.

How to turn behavior subject into observable in RxJava 2?

Dims
  • 47,675
  • 117
  • 331
  • 600

2 Answers2

18

From the What's different in 2.0 page, from 1.x Observable to 2.x Flowable :

asObservable : renamed to hide(), hides all identities now

So it seems that the hide method is what you are looking for.

Arnaud
  • 17,229
  • 3
  • 31
  • 44
12

You're probably looking for Observable.hide()

Hides the identity of this Observable and its Disposable. Allows hiding extra features such as Subject's Observer methods or preventing certain identity-based optimizations (fusion).

Kiskae
  • 24,655
  • 2
  • 77
  • 74