I tried googling this but results are all about what's changed between rxjava 1 and 2... less than helpful, lol.
I'm new to Rx Java and am working through it. I'm able to create an observable pretty easily and all subscribers are getting the right calls. I just have a question:
Object myObject = something1;
I create the observable and all subscribers and they get myObject in the onNext() method.
But, somewhere down the line, we do "myObject = something2".
How do I notify the subscribers that myObject has changed?
Here's how I'm creating the observable:
Observable<MyObject> myObservable = Observable.create(new ObservableOnSubscribe<MyObject>() {
@Override
public void subscribe(ObservableEmitter<MyObject> e) throws Exception {
MyObject myObject = someObject1;
e.onNext(myObject);
}
});
Here's how I'm subscribing:
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
myObservable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(mDisposableObserver);
}
private DisposableObserver<MyObject> mDisposableObserver = new DisposableObserver<MyObject>() {
@Override
public void onNext(MyObject myObject) {
// Do UI stuff with 'myObject' variables
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
};
Side Note: If anybody has links or suggestions to really good Rx Java 2 tutorials (like... super beginner through god-status), I'd greatly appreciate it