Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Dorus
    @Dorus
    @fAns1k Not sure if that's the cleanest way, but it should do the job.
    fAns1k
    @fAns1k
    i can’t catch where the right brackets here
    Dorus
    @Dorus
    Yeah my editor converted tabs to spaces. Should look better now.
    fAns1k
    @fAns1k
    yep, that’s more readable, thanks. will try
    Dorus
    @Dorus
    I'm not even sure if the Observable.create is needed. Might work with only Observable.just...
    fAns1k
    @fAns1k
    subscription here is also need?
    Dorus
    @Dorus
    Yes, for the Observable.create. This is without Observable.create:
        .flatMap(data -> 
            Observable.just(data)
            .map(data1 -> mapped)
            .compose(RxUtil.applyApiSchedulers())
            .map(__ -> data)
        )
    fAns1k
    @fAns1k
    is there any way to use ‘mapped’ object inside result subscription, like data and mapped object is needed
    Dorus
    @Dorus
    You can use zip where i used map(__ -> data)
    But you would still need a object that holds both data and mapped, or combine them in another meaningful way so subscribe can use it.
    fAns1k
    @fAns1k
    yep)
    Dorus
    @Dorus
    Actually no need for zip
    just .map(mapped -> combine(data, mapped)) etc.
    fAns1k
    @fAns1k
    it’s like the same as first solution - to use map -> and create result object
    Dorus
    @Dorus
    only you inject mapped in the end
    so no need to worry about it inbetween
    unpacking tuples in every map etc.
    fAns1k
    @fAns1k
    thank you very much for your help
    Dorus
    @Dorus
    Sure, glad i was of (some) help.
    @fAns1k : What you can do, is do your subscribe logic in the lat 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.
    fAns1k
    @fAns1k
    i need solution as readable as it can be, so i will play with it
    Dorus
    @Dorus
    I'm just throwing around some ideas :)
    fAns1k
    @fAns1k
    :D
    Dorus
    @Dorus
    I still have the feeling you're doing something wrong if you need data back in your subscription, so indeed something to think hard about and keep as readable as possible ;)
    fAns1k
    @fAns1k
    i get some data - create a stream - do requesti with data - get response - map - subscribe
    and inside onNext i need to have data.getId() [from the first step], that is my current logic
    Dorus
    @Dorus
    Yeah so you need a wrapper that keeps data.getId() and the response. Not much against that other than performance. The extra object lives very short anyway.
    fAns1k
    @fAns1k
    yeah))
    David Stemmer
    @weefbellington
    got an answer on ReactiveX/RxJava#3463
    the explanation feels a little funny to me as it seems like whether or not doOnTerminate is called after a downstream error is at the discretion of the operator
    seems a little bit like a leaky abstraction to me, but c'est la vie
    Ricardo Pallas
    @RPallas92
    thanks
    Jose Luis
    @josete89
    Could pass an argument to the onFinish method?
    Uppss sorry not here :D
    fAns1k
    @fAns1k
    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
    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
    firstOrDefault or startWith can help me, thanks
    David Stemmer
    @weefbellington
    this board has really sold me on Gitter
    are there any other interesting open source projects with very active gitter boards?
    Rudi Grinberg
    @rgrinberg
    I have an observable that’s a static instance variable in my application class on android
    but i keep either “losing” subscriptions to it somehow or it just dies
    is what i’m doing not supposed to work?
    Dorus
    @Dorus
    My gamble: You do not keep a reference to your Subscription and a over-eager GC collect it?
    Rudi Grinberg
    @rgrinberg
    @Dorus you’re right i don’t keep a reference in 1 subscription. But in other places in the code i control the lifetime explictly and they’re still lost. Let me add add a reference here see if it changes anything
    @Dorus no effect. Subscription is still lost.
    Dorus
    @Dorus
    Bad gamble then
    Rudi Grinberg
    @rgrinberg
    If it helps, the static observable is created from a static PublishSubject
    I tihnk i found my problem
    Dorus
    @Dorus
    i'm not sure how you create a observable from a PublishSubject