2021年1月29日星期五

Can this Swift code be simplified to remove the empty protocol and empty class?

Just learning Swift and cannot find a form of this code that compiles without the use of an empty protocol and empty class:

internal protocol JoinStudyEvent: Event where EventData == String  {  }    fileprivate class JoinStudyEventDirector: EventDirector<String>, JoinStudyEvent  {  }    internal class RegistrationView: UIWindow  {      private let _joinStudyRequestedEventDirector = JoinStudyEventDirector()            public var joinStudyRequestedEvent: some JoinStudyEvent      {          get          {              _joinStudyRequestedEventDirector          }      }  ...  }  

I would ideally like to type _joinStudyRequestedEventDirector as EventDirector<String> and joinStudyRequestedEvent as Event where EventData == String or similar without the need for explicit names. However I can't seem to find a simpler form than above that the compiler will accept. For reference EventDirector implements Event.

https://stackoverflow.com/questions/65962316/can-this-swift-code-be-simplified-to-remove-the-empty-protocol-and-empty-class January 30, 2021 at 06:02AM

没有评论:

发表评论