Search code examples
androidkotlinrx-java2

How to transform a list of one object to another in rx Java


Consider I have an object List<SShow> and I am trying to take this object and convert to List<Show>. I am able to do it for a single object but facing difficulty with parsing list here.

repository.getContentShow().map{
              Show.from(it.shows.get(0))
}

Please guide me how can I be able to parse a list to Show object.Thanks


Solution

  • repository.getContentShow().map{ 
              it.shows.map{ currentShow -> Show.from(currentShow) }
    }
    

    I think it should do the trick, just use kotlin Collection.map extension function with your list and return it from rxJava map function.