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
    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?
    Javier Domingo Cansino
    @txomon
        return Observable.concat(
                contactRepository.getContactList().flatMap((a) -> Observable.from(a)),
                contactRepository.getContactUpdates()
        );
    that was what I had done
    Michael Nitschinger
    @daschl
    okay
    Javier Domingo Cansino
    @txomon
    the thing is that I don't have really clear where should I do the buffering
    Michael Nitschinger
    @daschl
    what do you mean with buffering? who should buffer what?
    Javier Domingo Cansino
    @txomon
    sorry, I am mixing stuff
    Michael Nitschinger
    @daschl
    :)
    Javier Domingo Cansino
    @txomon
    so contactRepository is the data layer
    now I want that the business layer (where this function is), merges all the items until someone subscribes
    Michael Nitschinger
    @daschl
    aah now I see where you are going
    Javier Domingo Cansino
    @txomon
    that would be using contact repository to create a hot observable with all the items