Last active
November 1, 2020 13:40
-
-
Save Nyame123/8826d8314ac71fef359722fee65a912f to your computer and use it in GitHub Desktop.
Using create method to create Observables and subscribe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void createObservablesAndSubscribing() { | |
Observable observable = Observable.create(new ObservableOnSubscribe() { | |
@Override | |
public void subscribe(@NonNull ObservableEmitter emitter) { | |
emitter.onNext("Emitting new Stuff !!"); | |
emitter.onComplete(); | |
} | |
}); | |
observable.subscribe(new Observer<String>() { | |
@Override | |
public void onSubscribe(@NonNull Disposable d) { | |
} | |
@Override | |
public void onNext(String o) { | |
Log.d("RxJava Create", o); | |
} | |
@Override | |
public void onError(@NonNull Throwable e) { | |
} | |
@Override | |
public void onComplete() { | |
Log.d("RxJava Create","Observable consumed"); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment