Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Daniel Feist
    @dfeist
    With http inbound the connections are typically/optionally accepted immediately in selector (depending on framework) , then read/write events go on event loop. If system is overloaded connections stay open (until timeout) but aren't handled.. So they queue up as open/unhandled requests whch of course dont use threads.
    Ashok Raju
    @rajuashok

    Hi there, I'm trying to figure out how to chain to observables together. I have an existing method: public static Observable<Data> getData(). In my other class I have this existing code:

    doSomeBackgroundWork()
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(new Subscriber<..>() { ... })

    I'd like to now chain the getData() call to this call. How would I do this? I tried This initially:

    doSomeBackgroundWork()
    .flatMap(s -> call() {
       mApi.getData()
    }
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(new Subscriber<..>() { ... })

    But this doesn't work, because the getData() code is actually executed on the main thread.

    I need it to execute on the background thread just like the doSomeBackgroundWork() method.
    Ashok Raju
    @rajuashok

    This ended up working for me:

    doSomeBackgroundWork()
    .flatMap(s -> call() {
       return Observable.just(Data.empty());
    }
    .concatWith(mApi.getData().onErrorReturn(...))
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(new Subscriber<..>() { ... })

    There has to be a cleaner way of doing this right?

    ViTORossonero
    @ViTORossonero

    @rajuashok what does call() do?

    If you ignore result of doSomeBackgroundWork() you can use Completable instead:

    Completable doSomeBackgroundWork() {
    ...
    }
    
    
    doSomeBackgroundWork()
    .andThen(mApi.getData()
                 .onErrorReturn(...))
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(new Subscriber<..>() { ... })
    Alex Shpak
    @alex-shpak

    Hi guys!
    I recently worked on my library, and would like to collect some feedback.
    So please, If you have chance to check it or have some suggestion - that would be very appreciated!
    https://github.com/alex-shpak/rx-jersey

    It's RxJava support for Jersey framework (Server and Client sides). Looks like this:

    @Path("/")
    public class HelloResource {
    
        @Remote
        private HelloResource remote;
    
        @GET
        public Observable<String> getAsync() {
            return Observable.just("hello");
        }
    }
    Ghost
    @ghost~580ed9c0d73408ce4f309ef0
    He'll
    Srepfler Srdan
    @schrepfler
    nice @alex-shpak
    I haven’t worked with jersey for a while but I somehow do remember the core team was experimenting with rx-java couple of years ago IIRC
    Rajan na
    @Rajanna60227010_twitter
    Chat
    Alex Shpak
    @alex-shpak
    @schrepfler Hi!
    yes, Jersey has RxJava client, but not for resource interfaces. Which is implemented in library
    Srepfler Srdan
    @schrepfler
    ah, gotcha. thanks for the refresher
    ranjiexu
    @ranjiexu
    hi.
    Selina Li
    @ItsSelina
    Hey guys, can joint morphism be performed on observables? Ex. converting a list of observables to observable of list
    Scott Pierce
    @ScottPierce
    Does anyone have any examples of how to use the new ObservableOperator?
    it's to be used with the lift operator.
    moonsweel
    @moonsweel
    @ItsSelina flatMap?
    Alex Shpak
    @alex-shpak
    @ItsSelina
    Depends on behaviour that you want it might be:
    List<Observable<Object>> list = new ArrayList<>();
    Observable<List<Object>> result = Observable.from(list).flatMap(it -> it).toList();
    result = Observable.merge(list).toList();
    result = Observable.concatEager(list).toList();
    Scott Pierce
    @ScottPierce
    When should I use Observable.lift?
    I was trying to use it to create a new operator, but I'm finding it difficult
    Scott Pierce
    @ScottPierce
    I posted my above question on Stack Overflow in a little more detail: http://stackoverflow.com/questions/41834506/creating-custom-operators-in-rxjava2
    otaconix
    @otaconix
    Hey everyone. My question might be stupid, and if it is, feel free to just say so. I want to use an observable as sort of a pubsub mechanism. The easiest way seems to be to use a Subject, but I was also wondering how one might do this in some other, perhaps more idiomatic way. Question: what might this other, more idiomatic way, be?
    David Hoepelman
    @dhoepelman
    @otaconix Exactly what you subscribe is only possible with a subject (I’m assuming the streams are hot). More idiomatic would be to define clear input and output streams in each of the components and link those together.
    Justin Tuchek
    @justintuchek
    Is it weird that merge and concat from Single in RxJava 2.x push you into Flowable backpressure land? If you use either merge or concat on Observable your stay in a non-backpressured area.
    Patrik Johnson
    @orbitbot
    Hello, I'm fairly new to RxJava and RxAndroid, and while having some usages work, I'm now completely stumped by what I see as basic functionality not working. I have a subscribe call on a Subject that never seems to run, and I can't figure out why: https://gist.github.com/orbitbot/8f248e052bf0c2581d315bcccbc36029 -- sanity check logs from Line 74 shows that the Subject is updated, but code inside the Subscription Line 17 never gets called. What am I doing wrong?
    Patrik Johnson
    @orbitbot
    Patrik Johnson
    @orbitbot
    OK, found the issue, I'm using AsyncSubjects where I was actually expecting the functionality of BehavorSubjects.
    Stanislav Shakirov
    @punksta
    Petar Shomov
    @pshomov
    hello
    Petar Shomov
    @pshomov
    fellows, I am using RxJava 1.x and using a ReplaySubject to keep a trailing list of some values my app generates. I need to take the last N of that list (as it stands at the time of the invocation) and use them as another observable (a cold one) and use it to calculate something for one of my APIs. Seems since my original ReplaySubject never gets completed this whole idea falls apart. Any suggestions?
    ViTORossonero
    @ViTORossonero
    you can try .take(N) to create Observable that completes from ReplaySubject
    although if buffer of ReplaySubject is less than N items and it isn't full - .take(N) will wait till N items is emmited from ReplaySubject
    Petar Shomov
    @pshomov
    thank you @ViTORossonero. ReplaySubject has .getValues() which gives me back the items it has buffered for replay but unfortunately the time aspect of it is lost which is sort of a problem for any time-related operations in the "new" cold observable
    Luciano
    @lJoublanc
    @ViTORossonero try observable slidingBuffer (n,1) map ( list => Observable from calculateSomething(list) ) : Observable[ColdObservable[_]]
    You may use some of the other slidingBuffer methods if you want it the elements emitted within the last x seconds, rather than a #. See the API doc.
    Francisco A. Lozano
    @flozano
    Hi, quick q... if I have a Observable(myIterable).toBlocking().subscribe(some::thing), should I expect all the items in the observable to end up in memory?
    Luciano
    @lJoublanc
    @flozano Not sure if I recall correctly, but I don't think you have a 'subscribe' on blocking observable. Check the docs for 'BlockingObservable' - the answer to your Q depends on which call you use instead of 'subscribe'.
    e.g. using latest or next not all elems would be buffered.
    Alex Shpak
    @alex-shpak
    @flozano @lJoublanc
    I think .toList().toBlocking().first() should to the trick. And yes, you don't need to subscribe
    Luciano
    @lJoublanc
    @alex-shpak Not sure the he wants everything to be buffered.. not quite clear in his question.
    mmynsted
    @mmynsted
    What is the best way to repeat until an item emitted satisfies a particular quality? repeatUntil seems to be able to have a BooleanSupplier but BooleanSupplier would not inspect the item emitted. (Unless there is a way that I am not thinking of)
    mmynsted
    @mmynsted
    Here is an example using a callable, but I think that it should be possible to do this more rx like.
    Bojan Šernek
    @baadc0de
    A Flowable is put into a function (let's call it 'A') that returns a Flowable as well (let's call it 'B'). An implicit contract says that the new flowable will emit one item for every item emitted by the original Flowable, but not necessarily soon (there could be a .mapAsync and similar stuff in there). I would like to write a function that gets one item from 'A' and one item from 'B' in such a way that I know that what I got from 'B' was derived from what I got from 'A'. Hopefully that makes sense :)
    Bojan Šernek
    @baadc0de
    Would this work?
      override def apply(t: Flowable[AType]): Flowable[AType] = {
        t.flatMap(buffer => {
          Flowable.zip(f(Flowable.just(buffer)), Flowable.just(buffer), (processed: AType, unprocessed: AType) => {
            if (decision) unprocessed else processed
          })
        })
      }
    in this context f is the other function that returns the new 1:1 flowable
    Exerosis
    @Exerosis
    Is it possible to map one Observable to another using the scheduler specified with subscribeOn?
    Pavel Meledin
    @btbvoy

    Hi everyone, could somebody please give me a hint what a sequence of operators to use in order to have the following task done:

    1. As input for a stream I have pairs of (time and price)
    2. Then I need to group them per each 5 seconds based on time column, so I need to get a pair of (time and a list of prices)
    3. Then I need to convert each of pair of time and prices into the following format: case class Bar(time: Int, o: Int, h: Int, l: Int, c: Int, v: Int) where o - first price during this period of time, h - max price, l - lower price and c - just latest price appeared in a list.
    4. Then each such Bar needs to be sent further by stream to further subscribers.

    Very important to get an updated bar from point 4 for each time when new pair of time and price were pushed into the stream.

    Appreciate any help :-)

    ViTORossonero
    @ViTORossonero
    @btbvoy you can use smth like groupBy + scan
    items()
                .groupBy {
                    it.time / TimeUnit.SECONDS.toMillis(5)
                }
                .flatMap {
                    it.scan(ArrayList<Item>()) {
                        acc, el -> acc.add(el); acc
                    }
                            .filter { it.isNotEmpty() }
                            .map(::toBar)
    
                }
    although there're possible memory issues if items() is infinite