This is about an error encountered in https://github.com/RxSwiftCommunity/RxStarscream/pull/23.
I am trying to generalize a type, so I can mock the class it is based on. This means I want to switch from a concrete implementation to a protocol.
The original class looks like this:
open class WebSocket : NSObject, StreamDelegate, WebSocketClient, WSStreamDelegate { ... }
...
}
I want to replace this with this protocol, that WebSocket
is already extending:
public protocol WebSocketClient : AnyObject {
...
}
This means I am replacing
public class RxWebSocketDelegateProxy: DelegateProxy<WebSocket, NSObjectProtocol>, ... {
...
}
with
public class RxWebSocketDelegateProxy: DelegateProxy<WebSocketClient, NSObjectProtocol>, ... {
...
}
All of this seems easy enough — WebSocketClient
provides all the functionality that is needed here. Surprisingly, I am receiving the error message
'DelegateProxy' requires that 'WebSocketClient' be a class type
I am not sure what I am missing here and would appreciate pointers!