I have the following code:
interface UsersApi {
fun getUsers() : Single<List<UserTO>>
fun getPosts(postId: String) : Single<PostTO>
}
data class UserTO(val name: String, postIds: List<String>)
data class PostTO(val title: String, val content: String)
data class User(val name: String, val posts: List<Post>)
data class Post(val title: String, content: String)
I am trying to write a repository class with a method that returns
Single<List<User>>
But I have no idea how to do it, since I need access to earlier objects in the stream and also the Single is confusing things.
I am pretty sure I have to start with a call to getUsers followed by a flatmap, but then the things get confusing.
Any help?