Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Robert Winkler
    @RobWin
    Brings some scala flavour to java8
    Matt Langston
    @mattblang
    I’ve got an interesting situation I haven’t come across yet. I do several REST calls to register a user, log them in automatically, grab their profile, etc. I’m flat mapping all of these REST calls together. In my subscriber I handle a Throwable. The tricky part is, I need to be able to do something different depending on if they error during registration or after, because if the registration is successful but the auto login / profile fetch is not I don’t want them to try to log in again. Any hints?
    Andrew Reitz
    @pieces029
    @mattblang can you use doOnError after the call you want to specifically handle? Otherwise instance of in the onError, but that sounds gross.
    Matt Langston
    @mattblang
    @pieces029 I can doOnError from the first flatMap, sure, but will that stop the chain of flatMaps?
    Matt Langston
    @mattblang
    @pieces029 Yeah, so the doOnError hits but the onError in my subscriber still picks up the error as well. If I could somehow intercept the throwable and rethrow my own custom one maybe...
    Matt Langston
    @mattblang
    @pieces029 Okay, so I think I got it. Just do a doOnError for each step of the flatMap, rather than having an onError subscriber function
    Diego Magalhães
    @dgomesbr
    Could you use an either with left and right like in Scala? Do we have that in rx?
    Andrew Reitz
    @pieces029
    nice
    Robert Winkler
    @RobWin
    yes
    use the Try Monad
    you can also use some sort of Pattern matching in the error handler
    You can also look at https://github.com/RobWin/circuitbreaker-java8, if you need CircuitBreaker and Metrics support
    Robert Winkler
    @RobWin
    But unfortunately its Java8 only. Otherwise you can use http://www.functionaljava.org/
    Seivan Heidari
    @seivan
    Hi
    Dirk T.
    @DirkToewe
    Hello everyone. I appologize in advance for my ignorance. I haven't used RXJava before. But since it appears to be a well-maintained and very clean Java library, I was wondering if RXJava is suitable for the following two unrelated (ab)use cases:
    • System Dynamics: That would especially mean that feedback loops have to be feasible
    • As a Replacement for Bean Properties and/or JavaFX Properties: That would mean that (bidirectional) Bindings between Observables is possible
      I would be especially interested in examples for these uses.
    Simon Baslé
    @simonbasle
    hi Dirk, did you have a look at ReactFX (a RxJava-to-JavaFX binding library)?
    I don't know about your first point though...
    Dirk T.
    @DirkToewe
    ReactFX was exactly what i was looking for. It has all I need to work with JavaFX even without RXJava. Thank You, Simon!
    MightySeal
    @MightySeal
    Hello everyone. Have anyone implemented something similar to producer-consumer pattern using rxjava?
    I have tried using PublishSubject but it is not possible to limit background threads to 1. Is it possible?
    Simon Baslé
    @simonbasle
    @MightySeal how do you mean, limit background thread to 1?
    from a Producer-Consumer point of view, keep in mind that if no one subscribes to a PublishSubject it will kind of throw away the items fed to it (since it doesn't cache anything, and you only receive emissions that come after you subscribe)
    MightySeal
    @MightySeal
    @simonbasle it's ok. Limit threads — i mean i want only one task being executed in another thread and other tasks will wait until current is done.
    Moreover i would like to have possibility to add new tasks at any time i need.
    Simon Baslé
    @simonbasle
    do you use RxJava elsewhere? I'm not sure this approach fits well in the reactive model...
    sounds like an Executors.newSingleThreadExecutor()? (backed by a single-thread "pool" and an unbounded queue for queueing up tasks)
    in RxJava, Schedulers.computation() is close except its pool is sized to the number of CPUs
    MightySeal
    @MightySeal
    @simonbasle looks like. I'm new to rx and just trying to implement some tasks in this way. Thanks =)
    Simon Baslé
    @simonbasle
    mmh so if you want to do this in Rx, the submission of your tasks should be preceded by something like .observeOn(mySingleScheduler)
    what kind of tasks are you dealing with?
    where mySingleScheduler is prepared earlier as Schedulers.from(Executors.newSingleThreadExecutor())
    (where mySingleScheduler is prepared earlier as Schedulers.from(Executors.newSingleThreadExecutor()))
    (oups, sorry duplicate lines, lost the connection a bit so I wrote twice)
    MightySeal
    @MightySeal
    @simonbasle android file downloading. The whole idea is the following: i have a list of files, i start download and can add files to queue at any time. The files are not very large.
    Simon Baslé
    @simonbasle
    ah Android
    so you probably want to do the actual downloading in the background and then notify somehow on the UI thread?
    did you have a look at RxAndroid?
    MightySeal
    @MightySeal
    @simonbasle yes, already using it. But still can't figure out how to have only one task running simultaneously.
    Simon Baslé
    @simonbasle
    I'm not entirely sure (and maybe an Android dev here can confirm), but I think what you can do is something like
    //with s being a PublishSubject<String> or <URL>, and download() returning a status somehow
    final Scheduler singleScheduler = Schedulers.from(Executors.newSingleThreadExecutor());
    s
      .subscribeOn(singleScheduler)
      .map(s -> download(s))
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(status -> showStatusInUI(status));
    (I'm using lambda syntax for conciseness and readability here)
    MightySeal
    @MightySeal
    Yep, i'm familiar with lambdas =)
    Will try, thanks again
    MightySeal
    @MightySeal
    Well, looks like it's better to implement this feature as usual and use Observables for easier async behavoir handling.
    Vasco Figueira
    @vlfig

    Greetings all,

    I was looking at ways to throttle my async requests. I'm familiar with the "zip with a timer" pattern but I wanted something more akin to "limit number of in-flight requests".

    Any pointers?

    The setup is a typical Observable[SomeArgs]flatMapped with the Observable.from(httpResponseFuture)(RxScala, but details shouldn't be important here)
    Simon Baslé
    @simonbasle
    @vlfig what do you want to do if the number of requests is above your limit?
    drop some requests?