Browse Source

Add comments

Sebastian Thiebaud 7 years ago
parent
commit
e8530326a8
1 changed files with 7 additions and 0 deletions
  1. 7 0
      Sources/SwiftGRPC/Core/Channel.swift

+ 7 - 0
Sources/SwiftGRPC/Core/Channel.swift

@@ -89,10 +89,17 @@ public class Channel {
     return Call(underlyingCall: underlyingCall, owned: true, completionQueue: completionQueue)
   }
 
+  /// Check the current connectivity state
+  ///
+  /// - Parameter tryToConnect: boolean value to indicate if should try to connect if channel's connectivity state is idle
+  /// - Returns: a ConnectivityState value representing the current connectivity state of the channel
   public func connectivityState(tryToConnect: Bool = false) -> ConnectivityState {
     return ConnectivityState.connectivityState(cgrpc_channel_check_connectivity_state(underlyingChannel, tryToConnect ? 1 : 0))
   }
 
+  /// Subscribe to connectivity state changes
+  ///
+  /// - Parameter callback: block executed every time a new connectivity state is detected
   public func subscribe(callback: @escaping (ConnectivityState) -> Void) {
     let observer = ConnectivityObserver(underlyingChannel: underlyingChannel, currentState: connectivityState(), callback: callback)
     connectivityObservers.append(observer)