我有一个问题,我无法解决 . 我试图.zip(List,)使用Kotlin将多个Singles合并为一个,而我提供的函数都没有作为第二个参数适合 .
fun getUserFriendsLocationsInBuckets(token: String) {
roomDatabase.userFriendsDao().getUserFriendsDtosForToken(token).subscribe(
{ userFriends: List<UserFriendDTO> ->
Single.zip(getLocationSingleForEveryUser(userFriends),
Function<Array<List<Location>>, List<Location>> { t: Array<List<Location>> -> listOf<Location>() })
},
{ error: Throwable -> }
)
}
private fun getLocationSingleForEveryUser(userFriends: List<UserFriendDTO>): List<Single<List<Location>>> =
userFriends.map { serverRepository.locationEndpoint.getBucketedUserLocationsInLast24H(it.userFriendId) }
1 回答
问题是,由于类型擦除,
zipper
函数的参数类型是未知的 . 正如您在zip
的定义中所看到的:你必须使用
Any
作为你的数组的输入,并转换为你需要的任何东西: