RxJava – Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.
.map(mapped -> combine(data, mapped))
etc.
map
etc.
map
and use a empty .subscribe()
after the flatmap. Might be appropriate to use doOnEach
. Perhaps only part of your logic needs to be there. Not my favorite solution but at least it's readable.
doOnTerminate
is called after a downstream error is at the discretion of the operator
private Observable<Invoices> getInvoicesObservable(Invoices invoices) {
return invoices == null || invoices.getInvoices() == null ? Observable.empty()
: Observable.combineLatest(Observable.just(invoices), Observable.from(invoices.getInvoices())
.filter(invoice -> invoice.getStatus() == InvoiceStatus.UNPAID)
.toSortedList(), (Invoices rawInvoice, List<Invoice> invoiceList) -> {
rawInvoice.setInvoices(invoiceList);
return rawInvoice;
});
}
combileLatest(..,…, getInvoicesObservable)