These are chat archives for ReactiveX/RxJava

23rd
Oct 2015
fAns1k
@fAns1k
Oct 23 2015 07:59
hi all, how i can handle empty data inside flatMap, here is my code
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)
  • and in case with null data it never ends
Dorus
@Dorus
Oct 23 2015 09:08
combileLatest wont fire unless it receives at least 1 elements on both sides. You can add a default element with StartWith, or replace Observable.empty() with something else. Also combileLatest wont complete until all preceding observables complete. Perhaps end those on the left?
fAns1k
@fAns1k
Oct 23 2015 09:18
firstOrDefault or startWith can help me, thanks
David Stemmer
@weefbellington
Oct 23 2015 13:41
this board has really sold me on Gitter
are there any other interesting open source projects with very active gitter boards?