Skip to content

Instantly share code, notes, and snippets.

@ian-ellis
Created January 18, 2017 02:36
Show Gist options
  • Save ian-ellis/dea2d50776b39cd6a924c471309a058e to your computer and use it in GitHub Desktop.
Save ian-ellis/dea2d50776b39cd6a924c471309a058e to your computer and use it in GitHub Desktop.
public static <T> Observable.Transformer<T, T> doOnLast(Action1<T> doOnCompleteFunc) {
return new Observable.Transformer<T, T>() {
private T lastValue;
@Override
public Observable<T> call(Observable<T> observable) {
return observable.doOnNext(value -> {
lastValue = value;
}).doOnCompleted(() -> {
doOnCompleteFunc.call(lastValue);
});
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment