livekit / client-sdk-swift

LiveKit Swift Client SDK. Easily build live audio or video experiences on iOS, macOS, tvOS, and visionOS.
https://livekit.io
Apache License 2.0
198 stars 97 forks source link

Explicit delegate signatures #283

Closed hiroshihorie closed 9 months ago

hiroshihorie commented 9 months ago

A few delegates had the same signatures (by using overloading) such as:

room(_ room: Room, didUpdate speakers: [Participant]) room(_ room: Room, didUpdate metadata: String?) room(_ room: Room, didUpdate isRecording: Bool)

This pattern will break if add another method of the same type will be added in the future: room(_ room: Room, didUpdate isSomeExampleFlag: Bool)

Additionally, since labels can be omitted in Swift, the implementation side can be ambiguous:

func room(_: Room, didUpdate _: String?) {
  // ...
}

func room(_: Room, didUpdate _: Bool) {
  // ...
}

This PR makes delegate signatures explicit and future-proof by including the label in the signature:

room(_ room: Room, didUpdateSpeakingParticipants participants: [Participant]) room(_ room: Room, didUpdateMetadata metadata: String?) room(_ room: Room, didUpdateIsRecording isRecording: Bool)

I can deprecate the old methods, but since this will be part of v2 release maybe it's not required to deprecate.