1. RxSwift的Timer
private let queryUnreadMsgTimerStopped = BehaviorRelay(value: false)
private func startQueryUnreadMsgTimer() {
guard let reactor = self.reactor else {
return
}
queryUnreadMsgTimerStopped.accept(false)
Observable<Int>.interval(DispatchTimeInterval.seconds(60), scheduler: MainScheduler.instance).startWith(0).takeWhile{_ in
UserManager.isLogin
}.map{_ in
GWHHomeReactor.Action.queryUnreadCount
}.takeUntil(queryUnreadMsgTimerStopped.asObservable().filter{ $0 }).bind(to: reactor.action).disposed(by: disposeBag)
}
private func stopQueryUnreadMsgTimer() {
queryUnreadMsgTimerStopped.accept(true)
}