Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Michael Nitschinger
    @daschl
    okay
    so let me ask something
    Javier Domingo Cansino
    @txomon
    (I have deleted the other call which isn't interesting for the usecase)
    Michael Nitschinger
    @daschl
    okay gotcha I think, so whats the problem from there?
    Javier Domingo Cansino
    @txomon
    just in case, this is an app I am building to train myself in rx, android etc. so the idea is, the Observable<List<Contact>> getContactList() returns a cold observable and the Observable<Contact> getContactUpdates() returns a Hot observable
    Michael Nitschinger
    @daschl
    ah okay, so you mean that every time an update comes in a new contact is pushed?
    Javier Domingo Cansino
    @txomon
    yep
    Michael Nitschinger
    @daschl
    alright
    Javier Domingo Cansino
    @txomon
    the user of the interface is prepared to update contacts by having new objects sent directly
    Michael Nitschinger
    @daschl
    okay, and where is the trouble for you implementing?
    Javier Domingo Cansino
    @txomon
    so, the idea is to create a cold Observable<Contact> that, concatenates the return getContactList(), which has to be converted into Observable<Contact> items, and the buffered getContactUpdates return
    lets call cl to the return of getContactList(), cu to the return of getContactUpdates
    Michael Nitschinger
    @daschl
    so you want, every time Contact is emitted on the hot observable, “merge” it with the data on the cold one?
    Javier Domingo Cansino
    @txomon
    nope
    not here
    that is made by the user, now I need to generate a single stream of updates
    Michael Nitschinger
    @daschl
    okay, so you want to know how to create a hot observable?
    Javier Domingo Cansino
    @txomon
    the idea is to convert cl into an Observable<Contact> that emits all the items in cl
    Michael Nitschinger
    @daschl
    aah gotcha
    Javier Domingo Cansino
    @txomon
    then concatenate that to the output of cu
    this is the interface provided by the repository, meaning that I have an initial fetch, and updates to that initial fetch
    Michael Nitschinger
    @daschl
    So you wantfrom N List<Contact> to N * list.size() emits in the first step
    for the second part - you can’t concatenate on cu since its infinite, right?
    if we speak in rx concat terms
    Javier Domingo Cansino
    @txomon
    cl is Observable.just(List<Contact>)
    Michael Nitschinger
    @daschl
    why does clnot use Observable.from(List<Contact>) ?
    Javier Domingo Cansino
    @txomon
    hmmmm that would really simplify this xD
    Michael Nitschinger
    @daschl
    but even if you have many lists emitted
    you can simply extract it
    imagine:
    Observable.just(List, List, List).flatMap(l -> Observable.from(l)).forEach(println)
    that will flatten your original list into one emit for each containing element
    Javier Domingo Cansino
    @txomon
    oh...
    I didn't know flatMap() did that
    ok, so we have step one
    Michael Nitschinger
    @daschl
    well its not flatMap itself, but the combination of FlatMap and from
    Javier Domingo Cansino
    @txomon
    yes, I had done that, but with map instead of flatmap
    Michael Nitschinger
    @daschl
    yeah then you get the Observable<Observable>> thing
    :D
    Javier Domingo Cansino
    @txomon
    indeed xD
    Michael Nitschinger
    @daschl
    and flatmap “flattens” it out for you
    into one target observable
    Javier Domingo Cansino
    @txomon
    now the second step would be the concat
    Michael Nitschinger
    @daschl
    yes, but concat appens obs1 to obs2 when obs2 is done
    but your hot stream, is it finite or infinite?
    updates sounds infinite to me
    Javier Domingo Cansino
    @txomon
    cl is finite (one time) and cu is infinite
    so it would be to concat initialization + updates
    (initialization goes first)
    Michael Nitschinger
    @daschl
    ah well then did you try the concat operator?