in Sample/SwiftUI-MVVM/TicTacToe/Sources/Root/RootViewModel.swift [34:51]
func updateFeature() {
state = .loggedOut
if playersStreamCancellable != nil {
return
}
playersStreamCancellable = playerStream.names
.map { (names: (String, String)?) in
names == nil ? RootChildStates.loggedOut : RootChildStates.loggedIn
}
.removeDuplicates()
.sink(receiveValue: { [weak self] (state: RootChildStates) in
guard let strongSelf = self else {
return
}
strongSelf.state = state
})
}