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
    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
    Michael Nitschinger
    @daschl
    so first, even if one of the inner observables is hot, the outer one is cold so you’ll only see events if someone subscribes.. and what happens to the hot one below depends on the subject that you use
    Javier Domingo Cansino
    @txomon
    yeah, the concat needs something after it
    Michael Nitschinger
    @daschl
    keep in mind that hot observables, when wrapped, can become cold again (check Observable.defer for example)
    Javier Domingo Cansino
    @txomon
    sure
    Michael Nitschinger
    @daschl
    so you want to cache it basically?
    Javier Domingo Cansino
    @txomon
    I want to cache, deleting outdated items
    Michael Nitschinger
    @daschl
    there is a cache operator ;)
    Javier Domingo Cansino
    @txomon
    oh
    let me see..
    replay I think is the stuff you want
    and you can bound it so it throws away old stuff
    Javier Domingo Cansino
    @txomon
    but what I need to do is to create a cache that caches the latest items of every Contact id