title: How do I check for internet using Moya and RxSwift?
body: <p>As far as I understand <strong>Alamofire</strong> is pulled in with built in <strong>Reachability</strong>, so my own handler would look something like:</p>
  
  <pre><code>import Alamofire
  
  let reachabilityManager = NetworkReachabilityManager()
  reachabilityManager.listener = { status in
  
  switch status {
  
  case .notReachable:
   print("The network is not reachable")
   self.onInternetDisconnection()
  
  case .unknown :
   print("It is unknown whether the network is reachable")
   self.onInternetDisconnection() // not sure what to do for this case
  
  case .reachable(.ethernetOrWiFi):
   print("The network is reachable over the WiFi connection")
   self.onInternetConnection()
  
  case .reachable(.wwan):
   print("The network is reachable over the WWAN connection")
   self.onInternetConnection()
  
   }
  }
  </code></pre>
  
  <p>I'm making a request with:</p>
  
  <pre><code>let provider = MoyaProvider&lt;MyMoyaRequest&gt;()
  let token = provider.request(.start(
      username:self.email.value, 
      password: self.password.value) { result in
  
      switch result { 
      case let .success(moyaResponse):
          //handle success
      case let .failure(error):
          //handle failure
      }
  }
  </code></pre>
  
  <p>So if I want to have connectivity checked before every <strong>Moya</strong> Request is made what is the best way to go about it?</p>
  
  <ol>
  <li>Write an extension for one of Moyas internals to check first </li>
  <li>Use the Moya plugin (prepare) to check </li>
  <li>Some fancy pants other way so far unthought of...</li>
  </ol>
  
  <p>I specifically do <strong>not</strong> want to add a reachability check to every single API call, for readability reasons. But I am interested in hearing about methods previously used.</p>
  
  <p>Thank-you for any assistance you can offer.</p>