Any difference between "Subject.asObservable()" and the subject itself "Subject"?
android, kotlin, rx-java
Solution
if you look at the implementation of `.asObservable` you will see it lifts the observable with an operator that does nothing. This effectively just wraps your subject in an observable which makes it impossible for the consuming code to cast it back to a subject.
`asObservable` is a defense mechanism to hide implementation details and not much else.
Problem
If a `Subject` inherit from `Observable`, whats the difference the next options based on any `Subject` like: ``` private val locationSubject: ReplaySubject<Location> = ReplaySubject.create<Location>() ``` 1. Returning a `subject` itself as `Observable` ``` fun getLocations(): Observable<Location> = locationSubject ``` 2. Returning `subject.asObservable()`. ``` fun getLocations(): Observable<Location> = locationSubject.asObservable() ```