RxJava2-Java6 icon indicating copy to clipboard operation
RxJava2-Java6 copied to clipboard

BlockingObservable and NbpBlockingObservable use Optional.stream()

Open JakeWharton opened this issue 10 years ago • 3 comments

While the implementation could probably be changed upstream as the steam is just convenience, this needs reconciled either way.

JakeWharton avatar Oct 10 '15 19:10 JakeWharton

Another fix would just be to implement a subset of the stream API in the runtime. Then we don't have to rewrite anything...

JakeWharton avatar Oct 15 '15 23:10 JakeWharton

Each

  public Optional<T> firstOption() {
    return this.stream().findFirst();
  }

Needs rewritten to

  public Optional<T> firstOption() {
    return Iterables.firstOption(this);
  }

Where Iterables.firstOption is a util class in our runtime.

JakeWharton avatar Oct 16 '15 00:10 JakeWharton

Each

  public Optional<T> lastOption() {
    return this.stream().reduce((a, b) -> {
      return b;
    });
  }

Needs rewritten to

  public Optional<T> lastOption() {
    return Iterables.lastOption(this);
  }

Where Iterables.lastOption is a util class in our runtime.

JakeWharton avatar Oct 16 '15 00:10 JakeWharton