Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Artem Zinnatullin :slowpoke:
    @artem-zinnatullin
    @dstepanov take a look at PublishSubject, it can replace almost every Event Bus implementation.
    Denis Stepanov
    @dstepanov
    @artem-zinnatullin Thanks, that is exactly what I was looking for
    Artem Zinnatullin :slowpoke:
    @artem-zinnatullin
    @dstepanov glad to help :)
    Matt Langston
    @mattblang
    How could I stop the calls in a flatMap if an error happens somewhere in the chain?
    http://stackoverflow.com/q/31440271/1747491
    Andrew Reitz
    @pieces029
    Just wondering, why are you forcing the schedular back on the main thread a bunch?
    Don't you want to run in the background until you have your results (granted retrofit will force it on the background anyways).
    Also, the answer seems correct, what do you not like about it?
    Matt Langston
    @mattblang
    @pieces029 I need to update the progress UI along the way as I retrieve various data (auth token, then progress, etc.), which requires coming back to the main thread. I made a comment on the answer as to why it didn’t work. I was originally trying to do it like that.
    Yuriy Badalyantc
    @LMnet
    Hi everybody. Is there any "statefull reactive variable" in rx? Something like finite state machine?
    Denis Stepanov
    @dstepanov
    Do I understand correctly that if a subscriber throws an exception it'll be unsubscribed?
    Is there a way to keep the failing subscriber?
    Artem Zinnatullin :slowpoke:
    @artem-zinnatullin

    2 Ways:

    1) Don't throw exception as error signal, because it terminates Observable
    2) Materialize operator

    Denis Stepanov
    @dstepanov
    I'm using PublishSubject and I would like to catch an exception at onNext if any of the subscribers throws an exception
    Artem Zinnatullin :slowpoke:
    @artem-zinnatullin
    Matt Langston
    @mattblang
    has anyone used TestSubscriber for unit testing? I’m trying to assertError, but I am getting an AssertionError that Exceptions differ. However, it says java.net.SocketTimeoutException and the actual should be java.net.SocketTimeoutException
    Matt Langston
    @mattblang
    Wups, it is because assertError needs the .class, because Throwable doesn’t implement .equals, thus doing a reference comparison
    Dirk T.
    @DirkToewe
    Is there a Software/Tool/Plugin that allows to connect Observables similar to Matlab Simulink or Maybe in the Form of the Marble Diagrams?
    I forgot the most important key adverb: VISUALLY :smile:
    David Stemmer
    @weefbellington
    @DirkToewe maybe you could try http://rxmarbles.com/?
    I'm not sure if that's exactly what you want
    Bartłomiej Hołota
    @bholota
    I'm trying to understand defer(), should I use it in case when I'm creating Observable from list of Strings, map those into File and just after that subscribe to it? Should this observable be deffered or not?
    Dorus
    @Dorus
    Defer is for lazy evaluation. Use it if you need lazy evaluation.
    Bartłomiej Hołota
    @bholota
    Ok, so in cases when I want wait with emission until someone subscribe to it, right?
    Dorus
    @Dorus
    Yes, as normal for cold observables. There are multiple ways to accomplish that, and defer is one. I believe Observable.create() and many others can do the same.
    Bartłomiej Hołota
    @bholota
    ok, one more thing: when I will Observable.from(...).map(...).subscribe(...) and in such chaining this subscribe will catch all emitted items? It don't has to be defered? (it's hot observable right?)
    Artem Zinnatullin :slowpoke:
    @artem-zinnatullin
    1. It's not hot observable
    1. subscriber will catch all items
    1. It needs to be deferred only if in from(something) something should be computed only after subscription to the observable
    ah, sorry for indexes, markdown…
    About defer: imagine you have Observable.just(networkRequest())
    Artem Zinnatullin :slowpoke:
    @artem-zinnatullin
    the problem is that in Java all arguments computed before execution of the function, so you can not schedule networkRequest() on the other thread, it will be computed in thread that called Observable.just(networkRequest()).
    To avoid that you need to have a function that wraps your call and defer it:
    Observable
      .defer(() -> Observable.just(networkRequest())
      .map()
      .subscribe()
    this will be cold observable and networkRequest() will be executed only after subscription.
    Bartłomiej Hołota
    @bholota
    Ok, thanks, I need to read more about it.
    Abhinav Solan
    @eyeced
    I am doing an insert into DB wihich are single value inserts mostly coming from numerous clients, these are around 50k values coming in from different sources every 3 seconds, I am not able to do a batch insert into the db. Is their a way with obsevables that before calling on insert I can combine all of these into a single observable stream .. and all other observables are pushing into this defined observable ?
    David Stemmer
    @weefbellington
    @eyeced how often do you want do do the batch insert?
    is there something that triggers an end-of-stream -- like a sentinal value that says "this is the last thing to be inserted into the database"?
    or some sort of event that would allow you to figure out when the batch insert should occur?
    Abhinav Solan
    @eyeced
    These are continuos values coming no end of stream
    David Stemmer
    @weefbellington
    @eyeced alright, so what I might try is sample -- should allow you to sample a continuous stream of values at a specified interval, returning the values since the last sample as a Collection
    Abhinav Solan
    @eyeced
    Should I create one observable like batcher in the class and then call on merge for all incoming observables and use the window / batch option with time for the batcher observable and keep on doing batch insert using that .. would this be a good solution ?
    David Stemmer
    @weefbellington
    alternatively you could try buffer which allows you split the observable stream into fixed-sized chunks, for example if you wanted to do a batch update each time 1000 events were queued up
    looks like buffer supports sampling as well so that might be what you want
    @eyeced ^
    Abhinav Solan
    @eyeced
    So is should I just create common observable and merge in all the incoming observables in that .. and use buffer with that ...
    David Stemmer
    @weefbellington
    yep
    Abhinav Solan
    @eyeced
    thanks a lot @weefbellington
    David Stemmer
    @weefbellington
    sure
    Abhinav Solan
    @eyeced
    I did a setup for cassandra cluster which was giving around 60k inserts performance .. when I used single insertes it came down 20k inserts .. I will try out with this suggestion .. this might put it back to original performance