Answer the question
In order to leave comments, you need to log in
How to make N-number of requests and send their result to the server [RXjava]?
Request to create tags = N (any) number of requests for the same thing, for example, create a tag (the request returns the created tag with an ID)
Saving a list of tags to the user = One request in which you need to fit a list of results from tags (list of IDs)
How to implement it correctly such an idea in RXjava?
Answer the question
In order to leave comments, you need to log in
If I understand the question correctly, then something like this.
Single<Long> createTag(String tag) {
// creating tag, returning long id
}
Single<List<Long>> createTags(List<String> tags) {
return Observable.fromIterable(tags)
.flatMap(this::createTag)
.toList();
}
Completable attachTagsToUser(List<String> tags, User user) {
return createTags(tags)
.flatMapCompletable(tagIds -> /* do what you want, here the ids */);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question