Skip to content

Instantly share code, notes, and snippets.

@anitaa1990
Created August 19, 2018 08:48
Show Gist options
  • Save anitaa1990/0c8904c35e50a1c42e70186df02c6149 to your computer and use it in GitHub Desktop.
Save anitaa1990/0c8904c35e50a1c42e70186df02c6149 to your computer and use it in GitHub Desktop.
Observable.just("A", "BB", "CCC", "DDDD", "EEEEE", "FFFFFF") // UI
.map(str -> str.length()) // UI
.observeOn(Schedulers.computation()) //Changing the thread
.map(length -> 2 * length)
.subscribe(new Observer<Integer>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Integer integer) {
System.out.println("2 * length of string: " + integer);
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment