Currently I'm building a project in Kotlin using RxKotlin. My background with Rx is primarily grounded in RxJS.
A pattern I would regularly use for creating hot observables
in Typescript would look something along the lines of this:
private dataStore: IFoo;
private dataStoreSubject: BehaviorSubject<IFoo> = new BehaviorSubject(this.dataStore);
public dataStoreObservable: Observable<IFoo> = Observable.from(this.dataStoreSubject);
public getNetworkData(): Observable<IFoo[]> {
return this.http.get()
.map((response: IResponse) => {
this.dataStore = <IFoo[]>response;
this.dataStoreSubject.next(this.dataStore);
return this.dataStore;
});
}
This would allow me to expose an Observable
, without exposing the Subject
and subsequently the subject.next();
method.
My question is: What would be the most idiomatic way to establish similar logic in RxKotlin or RxJava?