我正在尝试从我要合并的两个流中过滤掉某些内容。我尝试使用的两个值属于同一类型,因此我似乎无法理解为什么会遇到此问题。
let currentUserEmail = Observable.just(currentUserEmail)
.unwrap()
//使用某种内部方式来访问电子邮件
let listOfAllUsers = Observable.combineLatest(getUsersList(), currentUserEmail) { allUsers, currentUserEmailAddress in
return allUsers.filter { $0.emailAddress != currentUserEmailAddress } }
.asObservable()
.share(replay: 1, scope: .whileConnected)
let currentUserEmail = currentUserEmail
let listOfAllUsers = getUsersList()
.asObservable()
.share(replay: 1, scope: .whileConnected)
let newListOfAllUsersWithoutCurrentUser = listOfAllUsers.map { allUsers in
allUsers.filter { $0.emailAddress != currentUserEmail }
}
.share(replay: 1, scope: .whileConnected)
最后这对我有用。