Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Michael Zinn
    @RedNifre
    I COULD add a synchronous "getCredentials" method to the persistence, but I hope there's a way to have the Observable<Credentials> to be the only source of credentials comming from the persistence.
    Fabricio
    @ofabricio
    then thats it.
    getCredentials().take(1).subscribe(cred => {
      if (cred == null) return;
      nameField = cred.name; 
      etc.
    });
    getCred stream must be a behaviorSub
    Michael Zinn
    @RedNifre
    Currently, the cred can't be null, the observable only emits valid credentials at the moment.
    Fabricio
    @ofabricio
    but the credential is filled in the login right?
    Michael Zinn
    @RedNifre
    if there are persisted credentials those will be filled into the dialog when the dialog opens. When the user entered credentials and hits save, the dialog pushes those credentials into another BehaviorSubject which is also injected in the persistence. The persistence then first saves those credentials and then pushes it to the other BehaviorSubject, which is also the one the dialog subscribes to. On startup, the persistence also pushes the credentials into the BehaviorSubject, if they exist.
    Fabricio
    @ofabricio
    so you're afraid it'll replace the field?
    Michael Zinn
    @RedNifre
    It won't happen in practice because the dialog is the only thing writing to the persistence and the dialog closes when you save. It works, but it doesn't feel correct.
    Fabricio
    @ofabricio
    but with take(1) it won't replace
    Michael Zinn
    @RedNifre
    Well, if I put an initial null in.
    Michael Zinn
    @RedNifre
    Well, given that it works I guess I'll leave it at that.
    Thank you for your help :)
    Fabricio
    @ofabricio
    when the user starts typing anything you could unsubscribe too
    Michael Zinn
    @RedNifre
    Oh, that's a good idea.
    Fabricio
    @ofabricio
    getCredentials().takeUntil(typing$)
    Michael Zinn
    @RedNifre
    Another thing: The persistence provides an Observable<Credentials> where the credentials contain a URL, username and password, right? I'd like to make retrofit calls to that url with username and password as basic auth parameters. How do I map that Observable<Credentials> to an Observable<StuffYouCanGetFromThatRetrofitCall> ?
    Hm, that might be more of a Retrofit question than an RxJava question I guess...
    Fabricio
    @ofabricio
    If I understood, that's a simple .mergeMap(cred => anotherCall(cred)), the stuff abt retrofit I dunno :smile:
    Denis Stoyanov
    @xgrommx
    @ofabricio do u use js examples? :smile:
    Fabricio
    @ofabricio
    @xgrommx it's universal :laughing:
    Denis Stoyanov
    @xgrommx
    I know that it is true (as u remember I also use js for .net and java rx)
    one interface and contract and too much implementations :smile:
    Denis Udovcic
    @dudovcic
    Hey, Im in need to learn Java for a job interview soon, any recommendations in fastest way to learn most of Java OOP + SQL implementation with the language ?
    Im already familiar with Nodejs and PHP + frameworks for those two so Im not a complete beginner
    Shahar Yakir
    @shaharyakir

    Hi, I'm building an app, in which I have a list of images, each is loaded asynchronously.
    Each time an item in the list is required to display its content it makes a request like so (pseudo-code):

    dataAccess.loadImage(url).subscribe(data => cell.imgData = data)

    Now, a button which causes the list to refresh and load all its cells can be pressed numerous times by the user.

    What happens now is that previous requests of the loadImage method are showing even if they do not belong to the current request.

    I could assign a request id and verify upon the load request finish that the ids still match, but I'd really like to cancel the request if it's no longer needed, and also to find a more ReactiveX way of doing so.

    My thinking is that I should be able somehow to build an observable stream that would include both the user initiated requests and the responses and to somehow zip them together, but I'm not sure how to approach that, since I'm opening a different sequence for each cell...

    Mark Elston
    @melston
    Or you could keep the subscription information and unsubscribe from the previous subscription when a new button press happens.
    Felix
    @fx42
    Hey guys. I've to write a paper about reactive programming. My professor asked me to make an example, something like an system monitor. So im quite new to this topic and the question is, If i want the get for e.g. the cpu usage for the cores of the machine, I need to make a call for this Information myself like every second. This doesnt deliver the result i want, because the calls for all the Information from the machine produce lots of load itself. Do you guys have a good idea of on small application to get a real data stream i can observe and represent in a gui? TL;DR: -> Looking for a good example to show of the features of Rx
    Oleh Dokuka
    @OlegDokuka
    @fx42 Have you tried to use some kind of Java profilers? For example JProfiler
    Felix
    @fx42
    i dont get the use of the profiler in my situation. Maybe it wasnt a good description from my side. I have to imlement a system monitoring tool myself using RxJava. The problem im humbling with, is that when I ask for the cpuload every second, and the request needs the Information from outside the JVM it produces quite a lot of system load itself. So like I said, Im not sure how a profiler could be of help. Maybe you can explain you intention a little further
    Neil Okamoto
    @gonewest818
    polling cpu usage once per second shouldn't be producing "quite a lot of system load." I would check first if you are reading that value just once per second instead of, for instance, as fast as possible.
    Troy Patrick
    @teasp00n
    hey guys, im having trouble with a unit test which requires using a test scheduler. im just trying to assert that an observable is being correctly debounced. ive had a bit of a google but cant find any samples using rxjava (found some rxjs ones but the test scheduler api looks different to what im seeing in rxjava)
    Ivan Schütz
    @i-schuetz
    Hi. I just started learning RxJava and I have a question. I have a use case where subscribing to certain events is coupled with producing these events. I.e. the subscription is what causes the event to start being emitted. Is this a common scenario? How would I implement it using RxJava?
    Ivan Schütz
    @i-schuetz
    this seem to be actually trivial. It would probably be something like e.g. snippet above in this chart dataAccess.loadImage(url).subscribe(data => cell.imgData = data)
    Ivan Schütz
    @i-schuetz
    what I'm looking for basically seems to be a cold observable
    Yannick Lecaillez
    @ylecaillez
    Hi ! I've a question regarding GroupBy. I actually want a GroupByUntil so i'm using a GroupBy() + takeWhile() on the GroupedFlowable.
    Problem is that GroupBy() is cancelling the upstream source when the last GroupedFlowable has been cancelled. (https://github.com/ReactiveX/RxJava/blob/a00ea07a4d2ce409e8dbea66ddbca9c0a77ddab6/src/main/java/io/reactivex/internal/operators/flowable/FlowableGroupBy.java#L204) This seems wrong to me: The upstream source should be cancelled only if the Flowable<GroupedFlowable<K,T>> is cancelled. WDYT ?
    My use case is a stream of multiplexed response packet which has to be grouped to their corresponding request. Basically a Flowable<GroupedFlowable<Request, Response>> responses = streamOfMultiplexedResponse.groupBy(responseMmessage.getRequestId());
    David Karnok
    @akarnokd
    The souce is cancelled if both the main sequence of groups and each individual group is cancelled. With takeWhile on the group, you cancel the current group but the group may be reopened if the key appears later from the upstream - which is not the case with Request I presume. Unless you cancel the outer Flowable, cancelling the inner GroupedFlowables should not stop the creation and emission to other groups.
    Yannick Lecaillez
    @ylecaillez
    I made a unit test and indeed, you're right: cancelling the inner GroupedFlowables does not stop the creation and emission to other groups. I have misunderstood the code. Thanks a lot ! and sorry for the noise :)
    Felix
    @fx42
    short question: Observable.interval( 10, TimeUnit.MILLISECONDS ).subscribeOn( Schedulers.computation() )
    .map( i -> methodGeneratingDoubleArray())
    I now want to flatMap(array -> Observable.from(array) ) but i see this wont work with rxjava2
    what is the way to go here?
    DavidMihola
    @DavidMihola
    fromArray?
    Felix
    @fx42
    this wont work
    when i then subscribe i still have to work with the array
    Erik Buttram
    @erito
    what about something like flatMapIterable? If the array is primitive you may be stuck unwrapping it yourself with fromCallable or create
    DavidMihola
    @DavidMihola
    I still think that fromArray should work:
            Observable.just(new Integer[]{1,2,3})
                    .flatMap(new Function<Integer[], Observable<Integer>>() {
                        @Override
                        public Observable<Integer> apply(@NonNull Integer[] ints) throws Exception {
                            return Observable.fromArray(ints);
                        }
                    })
                    .subscribe(new Consumer<Integer>() {
                        @Override
                        public void accept(@NonNull Integer integer) throws Exception {
    
                        }
                    });
    Vladimir Baryshnikov
    @vovkab

    Hello.

    Any idea how can I achieve next:
    I have stream of items, for specific type I need to wait for 1 sec, and if there is no more items of this type, let it keep moving down the stream, if there is more items of this type - wait total 5 seconds and collect everything, for all other item types just let them go as is.

    Vladimir Baryshnikov
    @vovkab

    I thought maybe I can do something like:

    events()
        .groupBy(event -> event.type() == type ? 0 : 1)
        .flatMap(grouped -> 
            if (grouped.getKey() == 0) {
                Observable closingSelector = grouped.debounce(1, TimeUnit.SECONDS);
                grouped
                    .buffer(closingSelector)
                    .map(agregate());
            } else {
                return grouped;
            }
        )

    But looks like I'm missing something about how groupBy is working, because I'm getting: java.lang.IllegalStateException: Only one Subscriber allowed!
    note: using rxjava-1

    VolodymyrBaisa
    @VolodymyrBaisa
    Привет народ как написать правильно Observable while
    Надо зделать loop который будет обновлять поле