These are chat archives for ReactiveX/RxJava

20th
Nov 2015
Javier Domingo Cansino
@txomon
Nov 20 2015 00:02
indeed there is @artem-zinnatullin there as contributor =)
maybe he can give us an insight...
Shapath Neupane
@TheShapGuy
Nov 20 2015 02:02
What is the best way to convert a nested list into a stream, https://www.reddit.com/r/androiddev/comments/3t1e9k/why_i_dont_use_realm_anymore/.json, Specifically asking about how to read comments from the Reddit API
Artem Zinnatullin :slowpoke:
@artem-zinnatullin
Nov 20 2015 04:06

whenever I see an application architecture that’s described as an acronym, I reach for my bazooka

@weefbellington same here, though usually such apps are not that bad, but "Clean" or "Reactive" makes me sad. Buzzwords.

@txomon you want me to give insight on what? Architecture of Android app with RxJava?
Abhinav Solan
@eyeced
Nov 20 2015 06:07
Hi @Dorus I tried this, but the next observable is not concatenating to the first one
This message was deleted
<T> Transformer<T, T> concatOnLast(T defaultValue, Func1<T, Observable<T>> nextObservable) {  
    return source -> Observable.create(o -> {
        ConnectableObservable<T> s1 = source.publish();
        Observable<T> s2 = s1.lastOrDefault(defaultValue) // return a default value if source 1 is empty. 
                .flatMap(e -> nextObservable.call(e)); // init source 2 here based on e.
        Observable.concat(s1, s2).subscribe(o);
        o.add(s1.connect());
    });
}
Abhinav Solan
@eyeced
Nov 20 2015 07:52
Got this working, needed to change the concat to (source and s2), thanks @Dorus for helping me understanding cancatenation
<T> Transformer<T, T> concatOnLast(T defaultValue, Func1<T, Observable<T>> nextObservable) {  
    return source -> Observable.create(o -> {
        ConnectableObservable<T> s1 = source.publish();
        Observable<T> s2 = s1.lastOrDefault(defaultValue) // return a default value if source 1 is empty. 
                .flatMap(e -> nextObservable.call(e)); // init source 2 here based on e.
        Observable.concat(source, s2).subscribe(o); // changing this from s1 to source
        o.add(s1.connect());
    });
}
Dorus
@Dorus
Nov 20 2015 10:48
@eyeced That looks wrong, you shouldn't be using source anymore after s1 = source.publish(), that defeats the entire purpose of publish.
Let me look into it
Dorus
@Dorus
Nov 20 2015 10:58
This message was deleted
This message was deleted
Dorus
@Dorus
Nov 20 2015 11:03
ooh i get it
concat wont subscribe to s2 right away.
static <T> Transformer<T, T> concatOnLast(T defaultValue, Func1<T, Observable<T>> nextObservable) {
    return source -> Observable.create(o -> {
        ConnectableObservable<T> s1 = source.publish();
        Observable<T> s2 = s1
                .lastOrDefault(defaultValue) // return a default value if source 1 is empty.
                .flatMap(e -> nextObservable.call(e)); // init source 2 here based on e.
        Observable.merge(s1, s2).subscribe(o);
        o.add(s1.connect());
    });
}
It's safe to use merge as s2 wont start until s1 completes.
Dorus
@Dorus
Nov 20 2015 11:12
I'm wondering if there is a way to convince concat to subscribe to both observables, just like merge has a maxConcurrent parameter.
Anyone know how to concat hot observables?
Javier Domingo Cansino
@txomon
Nov 20 2015 11:19
@artem-zinnatullin yes, organizing android app internally
Artem Zinnatullin :slowpoke:
@artem-zinnatullin
Nov 20 2015 11:26
@txomon well (imho disclaimer), I suggest MVP, all Rx stuff happens in Presenter and Model layer. Not sure I'm a fan of RxBinding (I use it from time to time, but since View layer is truly dummy and Presenter should not know details of View layer I'm not sure that providing observables from the View layer to Presenter is a good idea, though if such Observables don't expose View details — it's ok)
David Stemmer
@weefbellington
Nov 20 2015 14:20
it’s a framework that I’ve been working on for a while for View-based Android applications. I hestitate to call it an MVP framework but it certainly very strongly slanted toward separation of View presentation and display
kazemnejad
@kazemnejad
Nov 20 2015 21:39
Javier Domingo Cansino
@txomon
Nov 20 2015 22:28
@kazemnejad I have no idea, but the way I do it is creating an observable from the source (in your case downloader), and creating a subscriptor that receives those updates and updates the UI
before I link, I must warn that I am completely new to android and haven't created a great app yet, so I have no idea on how I can organize it really
but ...
for example creates an observable from a callable, and subscribes nothing yet
in the subscriber part you would have you UI update call