https://kotlinlang.org logo
#coroutines
Title
# coroutines
l

liminal

04/08/2020, 12:26 PM
It seems like this
map
and
filter
nesting should not be necessary. Any ideas how to improve it?
Copy code
filterByStarCountChannel.asFlow()
   .flatMapLatest { minStarCount ->
      userReposRepository.getUserRepos(username)
         .map { repoList ->
             repoList.filter { it.stars >= minStarCount.stars }
          }
       }
n

Nico Buescher

04/08/2020, 1:34 PM
your getUserRepos is returning a list of lists? Am I understanding that right? If not, what are you trying to do?
l

liminal

04/08/2020, 2:10 PM
GetUserRepos() returns Flow<List<Repo>>. I want to filter those repos based on minStarCount coming from the channel
n

Nico Buescher

04/08/2020, 2:23 PM
I’m not too familiar with the Flow concept, so given the structure of Flow<List<Repo>>, the map + filter combination is necessary. Perhaps there is a way to use a Flow<Repo> instead?
l

liminal

04/08/2020, 4:01 PM
No, I can’t use Flow<Repo>. Anyway, thanks for helping!
4 Views