RxJava通过匹配属性值来连接可观察流

时间:2016-03-13 10:56:48

标签: java rx-java reactive-programming

假设我有两个可观察的流

Observable<Book> books;
Observable<Movie> movies;

如果他们有匹配的属性,我该如何加入?像下面的psudo代码:

Observable<BookMoviePair> pairs = books.join(movies)
    .where((book, movie) -> book.getId() == movie.getId()))
    .return((book, movie) -> new BookMoviePair(book, movie));

1 个答案:

答案 0 :(得分:4)

一种方法:

r'C:\Users\NANA\Desktop\output'