     return ConnectivityState.connectivityState(cgrpc_channel_check_connectivity_state(underlyingChannel, tryToConnect ? 1 : 0))
   }
 
-  public func subscribe(callback: @escaping (ConnectivityState) -> ()) {
-    let observer = ConnectivityObserver(underlyingChannel: underlyingChannel, callback: callback)
-    observer.polling = true
+  public func subscribe(callback: @escaping (ConnectivityState) -> Void) {
+    let observer = ConnectivityObserver(underlyingChannel: underlyingChannel, currentState: connectivityState(), callback: callback)
     connectivityObservers.append(observer)
   }
 }

  }

  deinit {
    connectivityObservers.forEach { $0.polling = false }
    cgrpc_channel_destroy(underlyingChannel)
    completionQueue.shutdown()
  }

    private let completionQueue: CompletionQueue
    private let underlyingChannel: UnsafeMutableRawPointer
    private let underlyingCompletionQueue: UnsafeMutableRawPointer
    private let callback: (ConnectivityState) -> Void
    private var lastState: ConnectivityState
    
    init(underlyingChannel: UnsafeMutableRawPointer, currentState: ConnectivityState, callback: @escaping (ConnectivityState) -> ()) {
      self.underlyingChannel = underlyingChannel
      self.underlyingCompletionQueue = cgrpc_completion_queue_create_for_next()
      self.completionQueue = CompletionQueue(underlyingCompletionQueue: self.underlyingCompletionQueue, name: "Connectivity State")
      self.callback = callback
      self.lastState = currentState
      run()
    }

    deinit {
      completionQueue.shutdown()
    }

    private func run() {
      let spinloopThreadQueue = DispatchQueue(label: "SwiftGRPC.ConnectivityObserver.run.spinloopThread")

      spinloopThreadQueue.async { [weak self] in
        guard let `self` = self else { return }

        spinloop: while true  {
          guard let underlyingState = self.lastState.underlyingState else {
            print("Couldn't retrieve `underlyingState`")
            return
          }
          
          let deadline: TimeInterval = 0.2
          cgrpc_channel_watch_connectivity_state(self.underlyingChannel, self.underlyingCompletionQueue, underlyingState, deadline, nil)
          let event = self.completionQueue.wait(timeout: deadline)

          switch event.type {
          case .complete:
            let newState = ConnectivityState.connectivityState(cgrpc_channel_check_connectivity_state(self.underlyingChannel, 0))
            
            if newState != self.lastState {
              self.callback(newState)
            }
            
            self.lastState = newState
          case .queueShutdown:
            break spinloop
          case .queueTimeout:
            continue spinloop
          default:
            break spinloop
          }
        }
      }
    }
  }
}
