값을 전달
// TabBarController
func setupBindings() {
let HI = Observable
.just(())
.bind(to: viewModel.checkLocationAuth)
.disposed(by: disposeBag)
}
값을 받고 바인딩 시작
- flatMap : 들어온 옵저버블과 다른 옵저버블 방출 가능
// TabBarViewModel
class TabBarViewModel: TabBarViewModelType {
let disposeBag = DisposeBag()
var checkLocationAuth: AnyObserver<Void>
init(){
let checkingAuth = PublishSubject<Void>()
checkLocationAuth = checkingAuth.asObserver()
checkingAuth
.flatMap(LocationService.shared.requestLocation)
.bind { print($0) }
.disposed(by: disposeBag)
}
}