fix crash when NetworkService creates lazy in background thread (globalinit_*_func0)

This commit is contained in:
Ivan Smolin 2017-12-01 15:11:38 +03:00
parent 3969199df7
commit 7c92ef47e0
1 changed files with 6 additions and 3 deletions

View File

@ -26,9 +26,12 @@ extension NetworkService {
/// Let netwrok service automatically show / hide activity indicator
public func bindActivityIndicator() -> Disposable {
return requestCount
.map { $0 != 0 }
.drive(UIApplication.shared.rx.isNetworkActivityIndicatorVisible)
// Fatal error: `drive*` family of methods can be only called from `MainThread`
return DispatchQueue.main.sync {
requestCount
.map { $0 != 0 }
.drive(UIApplication.shared.rx.isNetworkActivityIndicatorVisible)
}
}
}