Last active
December 4, 2018 12:51
-
-
Save loromits/797ff4eabe9320dfe5ce572f74aec8a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Network | |
extension NWPathMonitor: ReactiveCompatible {} | |
extension Reactive where Base == NWPathMonitor { | |
func pathUpdate(on queue: DispatchQueue = .global(qos: .background)) -> Observable<NWPath> { | |
return Observable.create { [weak base] observer in | |
base?.pathUpdateHandler = observer.onNext | |
base?.start(queue: queue) | |
return Disposables.create { base?.cancel() } | |
} | |
} | |
} | |
NWPathMonitor(requiredInterfaceType: .cellular).rx.pathUpdate().subscribe() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment