Skip to content

Instantly share code, notes, and snippets.

@invasionofsmallcubes
Created February 7, 2017 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save invasionofsmallcubes/3ab1f60913e7003675a1fa8e7e5c0298 to your computer and use it in GitHub Desktop.
Save invasionofsmallcubes/3ab1f60913e7003675a1fa8e7e5c0298 to your computer and use it in GitHub Desktop.
static <T> Observable<T> just(T t) {
return Observable.create(
s -> {
s.onNext(t);
s.onCompleted();
}
);
}
static <T> Observable<T> never() {
return Observable.create(
s -> {}
);
}
static <T> Observable<T> empty() {
return Observable.create(
s -> {
s.onCompleted();
}
);
}
static Observable<Integer> range(Integer from, Integer to) {
return Observable.create(
s -> {
IntStream.range(from, to).forEach( i -> s.onNext(i));
s.onCompleted();
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment