Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    David Stemmer
    @weefbellington
    there is more to it, it calls an external payment service and sets up a listener object to listen for a result. The listener object pushes the result to onNext. I suppose that this is supposed to unsubscribe the internal listener if the Observable is unsubscribed from
    Dorus
    @Dorus
    ah right, missed the // some code here....
    o
    David Stemmer
    @weefbellington
    the pattern is pretty interesting though...I see that Scheduler.Worker implements Subscription so you could do some work on a thread or an event loop and bail when unsubscribe is called
    maybe that's obvious but it wasn't to me ¯_(ツ)_/¯
    Dorus
    @Dorus
    I've seen the pattern before so i was familiar with it, but the first time i strumbled on it, it was pretty confusing also.
    And that was in C#, the scheduler.Schedule() they have is slightly more complicated, with recursive scheduling and more fun stuff.
    Artem Zinnatullin :slowpoke:
    @artem-zinnatullin
    @weefbellington subscriber implements Subscription and unfortunately add() is non-obviously named method to release resources when Subscription will be unsubscribed
    Dorus
    @Dorus
    The weird part is that the RxJS people decided to ditch CompositeDisposable in favor of subscriber.add in the next major update.
    David Stemmer
    @weefbellington
    @artem-zinnatullin I had forgotten that Subscriber implements Subscription. Is there a use case for doing subscriber.add(secondarySubscriber)in Observable.OnSubscribe#call(subscriber)? Would all onNext, onError, onCompleted etc. calls that pass through the original subscriber be forwarded to the secondary subscriber?
    Dorus
    @Dorus
    @weefbellington no. The signature is add(Subscription s) and Subscription is an interface with only isUnsubscribed() and unsubscribe(), so it can't even forwards events.
    Artem Zinnatullin :slowpoke:
    @artem-zinnatullin
    @weefbellington nope, Subscription.add() is as I said just for triggering some code when origin subscription gets unsubscribed, usually it's a good place to remove listeners/etc and anything that may create memory leaks
    thought it's not needed for most RxJava use cases
    David Stemmer
    @weefbellington
    ah. I should have looked more closely at the Subscription interface. OK, makes sense, even if it's a little unintuitive
    Dorus
    @Dorus
    Totally unintuitive yes.
    Derek Perez
    @perezd
    Is there a way to use lambdas with subscribe but retain the expected argument type?
    I keep getting handed Object and have to cast
    Derek Perez
    @perezd
    I think the problem is that JDK8 cannot figure out what the functional interface is.
    Dorus
    @Dorus
    Like (String str) -> println(str)?
    You might also have lost the type in a previous operator, might need to hint the compiler there.
    Typing can be hard in Java, it's rather limited sometimes.
    David Stemmer
    @weefbellington
    is there a version of merge that outputs an Observable that completes if any of the source observables complete? It looks like merge will only complete if all of the source observables complete
    Bob van der Linden
    @bobvanderlinden
    Is there a way to easily convert an Observable to a BehaviorSubject?
    Dorus
    @Dorus
    .replay(1)?
    Bob van der Linden
    @bobvanderlinden
    hmm, let me look into that
    @Dorus That does indeed sounds like what I'm looking for. Thanks!
    Dorus
    @Dorus
    ^_^
    Bob van der Linden
    @bobvanderlinden
    do you think it would be helpful to have a shorthand for replay(1).refCount(), just like share() is for .publish().refCount(), or would that clutter the API too much?
    Dorus
    @Dorus
    replay(1).refCount() sounds totally useless. What's your usecase?
    Bob van der Linden
    @bobvanderlinden
    i have an observable that represents the state of my view. it needs to be able to refresh and there are multiple views that are watching that observable. so if the state changes, the views need to be updated
    so, that's why I was thinking of something like BehaviorSubject
    Dorus
    @Dorus
    ah ic, makes sense then
    So the first subscription activates the view and the rest listens in
    Bob van der Linden
    @bobvanderlinden
    but a separate BehaviorSubject is too much of an hassle when you have a Observable already
    multiple views subscribe to the 'state'. When the first subscription is made, a state-retrieval-process starts running. I don't want multiple subscriptions to trigger multiple state-retrieval-processes, i just want one to run when multiple views are interested in the same state.
    to be less abstract: it's about the USB state of Android
    Dorus
    @Dorus
    yeah, replay(1).refCount() totally solves that. Anyway i cant argue about the API surface thing as that's not to me to decided, i did already see some my feature requests shot down because of it :P
    Bob van der Linden
    @bobvanderlinden
    yes, sounds reasonable
    maybe i'll do an PR and see whether the maintainers find it acceptable. otherwise I'll just force myself to use kotlin+extension methods some more
    Boy Wang
    @boyw165
    A rx framework for Android:
    https://github.com/reark/reark
    systemfreund
    @systemfreund
    how can i convert an array/list of Observable<T> to an Observable<Observable<T>>?
    Dorus
    @Dorus
    List<Observable<T>> to Observable<Observable<T>>?
    Did you try Observable.from(list)?
    systemfreund
    @systemfreund
    of course.. slap i should go home
    thanks :D
    Roland Tepp
    @luolong
    Hey, I need advice of how would it be to proceed the best
    I have been playing around with RxJava for a week now and I’ve gotten some basic workflow working
    What I am currently doing: Reading files from a specified location line by line, then parsing those lines to a somewhat nicer structure and doing some analysis on that structure.
    What I want - since the whole operation can take a while, I want to present a nice progress bar while the part that reads files is processing.
    Dorus
    @Dorus
    How do you know the progress? Do lines contain information on that? Do you know the total nr of lines? filesize?