RxJava2 Iterate list and call single for every item












0














I have a database table with friend connections:



The next example is just a Imagined example, so please not suggest me to implement this in another way.



FriendConnection:




  • id

  • humanId


I have a list with these id's.



val friendConnections = arrayListOf(
FriendConnection(id=10, humanId=141),
FriendConnection(id=13, humanId=142)
)


I want to make this result list with RxJava.



val friendList = arrayListOf(
Friend(friendConnectionId = 10, humanId = 141, humanInstance = (...)),
Friend(friendConnectionId = 13, humanId = 142, humanInstance = (...))
)


How I can get a human?



fun getHumanById(id: Long) : Single<Human>


So I need to iterate the friendConnections and make a Single call for every Human. Than I need to map the FriendConnection with the new Human instance to Friend instance.



I tried it but it's not work:



Observable.fromIterable(arrayListOf(
FriendConnection(id=10, humanId=141),
FriendConnection(id=13, humanId=142)
))
.flatMapSingle { friendConnection ->
repository.getHumanById(friendConnection.humanId)
?.map {human ->
Friend(friendConnection.id,friendConnection.humanId,human)
}
}
.toList()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ it ->
Timber.i("friendList is here: $it")
}, {
throw it
})


Someone have idea what's wrong? (I want to implement it with Rx, not with Room)



enter image description here










share|improve this question
























  • What result do you have? Why safe call is used in repository.getHumanById(friendConnection.humanId)?.map if you have fun getHumanById(id: Long) : Single<Human> signature?
    – ConstOrVar
    Nov 21 at 10:57












  • Why you want to do this with Rx ? you can achieve this using kotlin operators itself. is your repository.getHumanById making call to API ?
    – Suryavel TR
    Nov 21 at 11:20










  • No, it's just a local database call.
    – vihkat
    Nov 21 at 11:39










  • Are you sure that fun getHumanById(id: Long) returns Single<Human> and not Single<Human>?(nullable type) ?
    – Andrey Ilyunin
    Nov 21 at 11:47












  • Because in the expressionrepository.getHumanById(friendConnection.humanId)?.map {...} question mark denotes nullable type.
    – Andrey Ilyunin
    Nov 21 at 11:49
















0














I have a database table with friend connections:



The next example is just a Imagined example, so please not suggest me to implement this in another way.



FriendConnection:




  • id

  • humanId


I have a list with these id's.



val friendConnections = arrayListOf(
FriendConnection(id=10, humanId=141),
FriendConnection(id=13, humanId=142)
)


I want to make this result list with RxJava.



val friendList = arrayListOf(
Friend(friendConnectionId = 10, humanId = 141, humanInstance = (...)),
Friend(friendConnectionId = 13, humanId = 142, humanInstance = (...))
)


How I can get a human?



fun getHumanById(id: Long) : Single<Human>


So I need to iterate the friendConnections and make a Single call for every Human. Than I need to map the FriendConnection with the new Human instance to Friend instance.



I tried it but it's not work:



Observable.fromIterable(arrayListOf(
FriendConnection(id=10, humanId=141),
FriendConnection(id=13, humanId=142)
))
.flatMapSingle { friendConnection ->
repository.getHumanById(friendConnection.humanId)
?.map {human ->
Friend(friendConnection.id,friendConnection.humanId,human)
}
}
.toList()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ it ->
Timber.i("friendList is here: $it")
}, {
throw it
})


Someone have idea what's wrong? (I want to implement it with Rx, not with Room)



enter image description here










share|improve this question
























  • What result do you have? Why safe call is used in repository.getHumanById(friendConnection.humanId)?.map if you have fun getHumanById(id: Long) : Single<Human> signature?
    – ConstOrVar
    Nov 21 at 10:57












  • Why you want to do this with Rx ? you can achieve this using kotlin operators itself. is your repository.getHumanById making call to API ?
    – Suryavel TR
    Nov 21 at 11:20










  • No, it's just a local database call.
    – vihkat
    Nov 21 at 11:39










  • Are you sure that fun getHumanById(id: Long) returns Single<Human> and not Single<Human>?(nullable type) ?
    – Andrey Ilyunin
    Nov 21 at 11:47












  • Because in the expressionrepository.getHumanById(friendConnection.humanId)?.map {...} question mark denotes nullable type.
    – Andrey Ilyunin
    Nov 21 at 11:49














0












0








0







I have a database table with friend connections:



The next example is just a Imagined example, so please not suggest me to implement this in another way.



FriendConnection:




  • id

  • humanId


I have a list with these id's.



val friendConnections = arrayListOf(
FriendConnection(id=10, humanId=141),
FriendConnection(id=13, humanId=142)
)


I want to make this result list with RxJava.



val friendList = arrayListOf(
Friend(friendConnectionId = 10, humanId = 141, humanInstance = (...)),
Friend(friendConnectionId = 13, humanId = 142, humanInstance = (...))
)


How I can get a human?



fun getHumanById(id: Long) : Single<Human>


So I need to iterate the friendConnections and make a Single call for every Human. Than I need to map the FriendConnection with the new Human instance to Friend instance.



I tried it but it's not work:



Observable.fromIterable(arrayListOf(
FriendConnection(id=10, humanId=141),
FriendConnection(id=13, humanId=142)
))
.flatMapSingle { friendConnection ->
repository.getHumanById(friendConnection.humanId)
?.map {human ->
Friend(friendConnection.id,friendConnection.humanId,human)
}
}
.toList()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ it ->
Timber.i("friendList is here: $it")
}, {
throw it
})


Someone have idea what's wrong? (I want to implement it with Rx, not with Room)



enter image description here










share|improve this question















I have a database table with friend connections:



The next example is just a Imagined example, so please not suggest me to implement this in another way.



FriendConnection:




  • id

  • humanId


I have a list with these id's.



val friendConnections = arrayListOf(
FriendConnection(id=10, humanId=141),
FriendConnection(id=13, humanId=142)
)


I want to make this result list with RxJava.



val friendList = arrayListOf(
Friend(friendConnectionId = 10, humanId = 141, humanInstance = (...)),
Friend(friendConnectionId = 13, humanId = 142, humanInstance = (...))
)


How I can get a human?



fun getHumanById(id: Long) : Single<Human>


So I need to iterate the friendConnections and make a Single call for every Human. Than I need to map the FriendConnection with the new Human instance to Friend instance.



I tried it but it's not work:



Observable.fromIterable(arrayListOf(
FriendConnection(id=10, humanId=141),
FriendConnection(id=13, humanId=142)
))
.flatMapSingle { friendConnection ->
repository.getHumanById(friendConnection.humanId)
?.map {human ->
Friend(friendConnection.id,friendConnection.humanId,human)
}
}
.toList()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ it ->
Timber.i("friendList is here: $it")
}, {
throw it
})


Someone have idea what's wrong? (I want to implement it with Rx, not with Room)



enter image description here







kotlin rx-java2






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 at 10:12

























asked Nov 21 at 10:07









vihkat

236315




236315












  • What result do you have? Why safe call is used in repository.getHumanById(friendConnection.humanId)?.map if you have fun getHumanById(id: Long) : Single<Human> signature?
    – ConstOrVar
    Nov 21 at 10:57












  • Why you want to do this with Rx ? you can achieve this using kotlin operators itself. is your repository.getHumanById making call to API ?
    – Suryavel TR
    Nov 21 at 11:20










  • No, it's just a local database call.
    – vihkat
    Nov 21 at 11:39










  • Are you sure that fun getHumanById(id: Long) returns Single<Human> and not Single<Human>?(nullable type) ?
    – Andrey Ilyunin
    Nov 21 at 11:47












  • Because in the expressionrepository.getHumanById(friendConnection.humanId)?.map {...} question mark denotes nullable type.
    – Andrey Ilyunin
    Nov 21 at 11:49


















  • What result do you have? Why safe call is used in repository.getHumanById(friendConnection.humanId)?.map if you have fun getHumanById(id: Long) : Single<Human> signature?
    – ConstOrVar
    Nov 21 at 10:57












  • Why you want to do this with Rx ? you can achieve this using kotlin operators itself. is your repository.getHumanById making call to API ?
    – Suryavel TR
    Nov 21 at 11:20










  • No, it's just a local database call.
    – vihkat
    Nov 21 at 11:39










  • Are you sure that fun getHumanById(id: Long) returns Single<Human> and not Single<Human>?(nullable type) ?
    – Andrey Ilyunin
    Nov 21 at 11:47












  • Because in the expressionrepository.getHumanById(friendConnection.humanId)?.map {...} question mark denotes nullable type.
    – Andrey Ilyunin
    Nov 21 at 11:49
















What result do you have? Why safe call is used in repository.getHumanById(friendConnection.humanId)?.map if you have fun getHumanById(id: Long) : Single<Human> signature?
– ConstOrVar
Nov 21 at 10:57






What result do you have? Why safe call is used in repository.getHumanById(friendConnection.humanId)?.map if you have fun getHumanById(id: Long) : Single<Human> signature?
– ConstOrVar
Nov 21 at 10:57














Why you want to do this with Rx ? you can achieve this using kotlin operators itself. is your repository.getHumanById making call to API ?
– Suryavel TR
Nov 21 at 11:20




Why you want to do this with Rx ? you can achieve this using kotlin operators itself. is your repository.getHumanById making call to API ?
– Suryavel TR
Nov 21 at 11:20












No, it's just a local database call.
– vihkat
Nov 21 at 11:39




No, it's just a local database call.
– vihkat
Nov 21 at 11:39












Are you sure that fun getHumanById(id: Long) returns Single<Human> and not Single<Human>?(nullable type) ?
– Andrey Ilyunin
Nov 21 at 11:47






Are you sure that fun getHumanById(id: Long) returns Single<Human> and not Single<Human>?(nullable type) ?
– Andrey Ilyunin
Nov 21 at 11:47














Because in the expressionrepository.getHumanById(friendConnection.humanId)?.map {...} question mark denotes nullable type.
– Andrey Ilyunin
Nov 21 at 11:49




Because in the expressionrepository.getHumanById(friendConnection.humanId)?.map {...} question mark denotes nullable type.
– Andrey Ilyunin
Nov 21 at 11:49












2 Answers
2






active

oldest

votes


















0














Is this solution suitable for you?



Observable.fromIterable(
listOf(
FriendConnection(1, 101),
FriendConnection(2, 102)
)
)
.flatMapSingle { connection ->
getHumanById(connection.humanId)
.map { human -> Friend(connection.id, connection.humanId, human) }
}
.toList()
.subscribe { list -> println(list) } //method reference generates error due to methods ambiguity


Mock function for getting a human by id:



private fun getHumanById(id: Long): Single<Human> = Single.just(Human(id, id.toString()))





share|improve this answer





















  • This does not work for me. I have 50 item in the friendConnection list, but only first 2 times called the flatMapSingle, why?
    – vihkat
    Nov 21 at 11:56












  • @vihkat, please, answer my comment under the question. Maybe the problem lies here. Also, it would be cool if we could know why it does not work. Compile-time error, run-time error, unexpected result?
    – Andrey Ilyunin
    Nov 21 at 11:57










  • It works with your mock. But not work with my Single, but I'm sure it not returning null because I burned in a fix ID witch is work good
    – vihkat
    Nov 21 at 12:02










  • Are you completely sure that getHumanById returns exactly Single<Human> ? It is not either Single<Human?> or Single<Human>? or even Single<Human?>? ?
    – Andrey Ilyunin
    Nov 21 at 12:29












  • Yes. I'm sure about it
    – vihkat
    Nov 21 at 12:33



















0














You could do something like this,



Observable.fromIterable(friendConnections)
.flatMap { Observable.just(Friend(it.id, it.humanId, repository.getHumanById(it.humanId).blockingGet())) }
.toList()
.subscribe {it --> /*Your Operation*/





share|improve this answer



















  • 1




    you need flatMap for getHumanById, not map
    – Tim Castelijns
    Nov 21 at 11:28










  • True. if repository.getHumanById makes API call then it should be flatMap. (Updated the answer based on assumption)
    – Suryavel TR
    Nov 21 at 11:42






  • 1




    there is no assumption, it doesn't matter what the method is doing. It returns a Single, therefore you need flatMap
    – Tim Castelijns
    Nov 21 at 11:43













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53409630%2frxjava2-iterate-list-and-call-single-for-every-item%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Is this solution suitable for you?



Observable.fromIterable(
listOf(
FriendConnection(1, 101),
FriendConnection(2, 102)
)
)
.flatMapSingle { connection ->
getHumanById(connection.humanId)
.map { human -> Friend(connection.id, connection.humanId, human) }
}
.toList()
.subscribe { list -> println(list) } //method reference generates error due to methods ambiguity


Mock function for getting a human by id:



private fun getHumanById(id: Long): Single<Human> = Single.just(Human(id, id.toString()))





share|improve this answer





















  • This does not work for me. I have 50 item in the friendConnection list, but only first 2 times called the flatMapSingle, why?
    – vihkat
    Nov 21 at 11:56












  • @vihkat, please, answer my comment under the question. Maybe the problem lies here. Also, it would be cool if we could know why it does not work. Compile-time error, run-time error, unexpected result?
    – Andrey Ilyunin
    Nov 21 at 11:57










  • It works with your mock. But not work with my Single, but I'm sure it not returning null because I burned in a fix ID witch is work good
    – vihkat
    Nov 21 at 12:02










  • Are you completely sure that getHumanById returns exactly Single<Human> ? It is not either Single<Human?> or Single<Human>? or even Single<Human?>? ?
    – Andrey Ilyunin
    Nov 21 at 12:29












  • Yes. I'm sure about it
    – vihkat
    Nov 21 at 12:33
















0














Is this solution suitable for you?



Observable.fromIterable(
listOf(
FriendConnection(1, 101),
FriendConnection(2, 102)
)
)
.flatMapSingle { connection ->
getHumanById(connection.humanId)
.map { human -> Friend(connection.id, connection.humanId, human) }
}
.toList()
.subscribe { list -> println(list) } //method reference generates error due to methods ambiguity


Mock function for getting a human by id:



private fun getHumanById(id: Long): Single<Human> = Single.just(Human(id, id.toString()))





share|improve this answer





















  • This does not work for me. I have 50 item in the friendConnection list, but only first 2 times called the flatMapSingle, why?
    – vihkat
    Nov 21 at 11:56












  • @vihkat, please, answer my comment under the question. Maybe the problem lies here. Also, it would be cool if we could know why it does not work. Compile-time error, run-time error, unexpected result?
    – Andrey Ilyunin
    Nov 21 at 11:57










  • It works with your mock. But not work with my Single, but I'm sure it not returning null because I burned in a fix ID witch is work good
    – vihkat
    Nov 21 at 12:02










  • Are you completely sure that getHumanById returns exactly Single<Human> ? It is not either Single<Human?> or Single<Human>? or even Single<Human?>? ?
    – Andrey Ilyunin
    Nov 21 at 12:29












  • Yes. I'm sure about it
    – vihkat
    Nov 21 at 12:33














0












0








0






Is this solution suitable for you?



Observable.fromIterable(
listOf(
FriendConnection(1, 101),
FriendConnection(2, 102)
)
)
.flatMapSingle { connection ->
getHumanById(connection.humanId)
.map { human -> Friend(connection.id, connection.humanId, human) }
}
.toList()
.subscribe { list -> println(list) } //method reference generates error due to methods ambiguity


Mock function for getting a human by id:



private fun getHumanById(id: Long): Single<Human> = Single.just(Human(id, id.toString()))





share|improve this answer












Is this solution suitable for you?



Observable.fromIterable(
listOf(
FriendConnection(1, 101),
FriendConnection(2, 102)
)
)
.flatMapSingle { connection ->
getHumanById(connection.humanId)
.map { human -> Friend(connection.id, connection.humanId, human) }
}
.toList()
.subscribe { list -> println(list) } //method reference generates error due to methods ambiguity


Mock function for getting a human by id:



private fun getHumanById(id: Long): Single<Human> = Single.just(Human(id, id.toString()))






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 21 at 11:45









Andrey Ilyunin

1,259220




1,259220












  • This does not work for me. I have 50 item in the friendConnection list, but only first 2 times called the flatMapSingle, why?
    – vihkat
    Nov 21 at 11:56












  • @vihkat, please, answer my comment under the question. Maybe the problem lies here. Also, it would be cool if we could know why it does not work. Compile-time error, run-time error, unexpected result?
    – Andrey Ilyunin
    Nov 21 at 11:57










  • It works with your mock. But not work with my Single, but I'm sure it not returning null because I burned in a fix ID witch is work good
    – vihkat
    Nov 21 at 12:02










  • Are you completely sure that getHumanById returns exactly Single<Human> ? It is not either Single<Human?> or Single<Human>? or even Single<Human?>? ?
    – Andrey Ilyunin
    Nov 21 at 12:29












  • Yes. I'm sure about it
    – vihkat
    Nov 21 at 12:33


















  • This does not work for me. I have 50 item in the friendConnection list, but only first 2 times called the flatMapSingle, why?
    – vihkat
    Nov 21 at 11:56












  • @vihkat, please, answer my comment under the question. Maybe the problem lies here. Also, it would be cool if we could know why it does not work. Compile-time error, run-time error, unexpected result?
    – Andrey Ilyunin
    Nov 21 at 11:57










  • It works with your mock. But not work with my Single, but I'm sure it not returning null because I burned in a fix ID witch is work good
    – vihkat
    Nov 21 at 12:02










  • Are you completely sure that getHumanById returns exactly Single<Human> ? It is not either Single<Human?> or Single<Human>? or even Single<Human?>? ?
    – Andrey Ilyunin
    Nov 21 at 12:29












  • Yes. I'm sure about it
    – vihkat
    Nov 21 at 12:33
















This does not work for me. I have 50 item in the friendConnection list, but only first 2 times called the flatMapSingle, why?
– vihkat
Nov 21 at 11:56






This does not work for me. I have 50 item in the friendConnection list, but only first 2 times called the flatMapSingle, why?
– vihkat
Nov 21 at 11:56














@vihkat, please, answer my comment under the question. Maybe the problem lies here. Also, it would be cool if we could know why it does not work. Compile-time error, run-time error, unexpected result?
– Andrey Ilyunin
Nov 21 at 11:57




@vihkat, please, answer my comment under the question. Maybe the problem lies here. Also, it would be cool if we could know why it does not work. Compile-time error, run-time error, unexpected result?
– Andrey Ilyunin
Nov 21 at 11:57












It works with your mock. But not work with my Single, but I'm sure it not returning null because I burned in a fix ID witch is work good
– vihkat
Nov 21 at 12:02




It works with your mock. But not work with my Single, but I'm sure it not returning null because I burned in a fix ID witch is work good
– vihkat
Nov 21 at 12:02












Are you completely sure that getHumanById returns exactly Single<Human> ? It is not either Single<Human?> or Single<Human>? or even Single<Human?>? ?
– Andrey Ilyunin
Nov 21 at 12:29






Are you completely sure that getHumanById returns exactly Single<Human> ? It is not either Single<Human?> or Single<Human>? or even Single<Human?>? ?
– Andrey Ilyunin
Nov 21 at 12:29














Yes. I'm sure about it
– vihkat
Nov 21 at 12:33




Yes. I'm sure about it
– vihkat
Nov 21 at 12:33













0














You could do something like this,



Observable.fromIterable(friendConnections)
.flatMap { Observable.just(Friend(it.id, it.humanId, repository.getHumanById(it.humanId).blockingGet())) }
.toList()
.subscribe {it --> /*Your Operation*/





share|improve this answer



















  • 1




    you need flatMap for getHumanById, not map
    – Tim Castelijns
    Nov 21 at 11:28










  • True. if repository.getHumanById makes API call then it should be flatMap. (Updated the answer based on assumption)
    – Suryavel TR
    Nov 21 at 11:42






  • 1




    there is no assumption, it doesn't matter what the method is doing. It returns a Single, therefore you need flatMap
    – Tim Castelijns
    Nov 21 at 11:43


















0














You could do something like this,



Observable.fromIterable(friendConnections)
.flatMap { Observable.just(Friend(it.id, it.humanId, repository.getHumanById(it.humanId).blockingGet())) }
.toList()
.subscribe {it --> /*Your Operation*/





share|improve this answer



















  • 1




    you need flatMap for getHumanById, not map
    – Tim Castelijns
    Nov 21 at 11:28










  • True. if repository.getHumanById makes API call then it should be flatMap. (Updated the answer based on assumption)
    – Suryavel TR
    Nov 21 at 11:42






  • 1




    there is no assumption, it doesn't matter what the method is doing. It returns a Single, therefore you need flatMap
    – Tim Castelijns
    Nov 21 at 11:43
















0












0








0






You could do something like this,



Observable.fromIterable(friendConnections)
.flatMap { Observable.just(Friend(it.id, it.humanId, repository.getHumanById(it.humanId).blockingGet())) }
.toList()
.subscribe {it --> /*Your Operation*/





share|improve this answer














You could do something like this,



Observable.fromIterable(friendConnections)
.flatMap { Observable.just(Friend(it.id, it.humanId, repository.getHumanById(it.humanId).blockingGet())) }
.toList()
.subscribe {it --> /*Your Operation*/






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 21 at 12:12

























answered Nov 21 at 11:18









Suryavel TR

2,36311418




2,36311418








  • 1




    you need flatMap for getHumanById, not map
    – Tim Castelijns
    Nov 21 at 11:28










  • True. if repository.getHumanById makes API call then it should be flatMap. (Updated the answer based on assumption)
    – Suryavel TR
    Nov 21 at 11:42






  • 1




    there is no assumption, it doesn't matter what the method is doing. It returns a Single, therefore you need flatMap
    – Tim Castelijns
    Nov 21 at 11:43
















  • 1




    you need flatMap for getHumanById, not map
    – Tim Castelijns
    Nov 21 at 11:28










  • True. if repository.getHumanById makes API call then it should be flatMap. (Updated the answer based on assumption)
    – Suryavel TR
    Nov 21 at 11:42






  • 1




    there is no assumption, it doesn't matter what the method is doing. It returns a Single, therefore you need flatMap
    – Tim Castelijns
    Nov 21 at 11:43










1




1




you need flatMap for getHumanById, not map
– Tim Castelijns
Nov 21 at 11:28




you need flatMap for getHumanById, not map
– Tim Castelijns
Nov 21 at 11:28












True. if repository.getHumanById makes API call then it should be flatMap. (Updated the answer based on assumption)
– Suryavel TR
Nov 21 at 11:42




True. if repository.getHumanById makes API call then it should be flatMap. (Updated the answer based on assumption)
– Suryavel TR
Nov 21 at 11:42




1




1




there is no assumption, it doesn't matter what the method is doing. It returns a Single, therefore you need flatMap
– Tim Castelijns
Nov 21 at 11:43






there is no assumption, it doesn't matter what the method is doing. It returns a Single, therefore you need flatMap
– Tim Castelijns
Nov 21 at 11:43




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53409630%2frxjava2-iterate-list-and-call-single-for-every-item%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'