amazon-chime-sdk-ios
amazon-chime-sdk-ios copied to clipboard
Make Observer protocol functions optional.
Is your feature request related to a problem? Please describe. I am required to implement observer handlers, even if I don't plan on responding to the event. Omitting any method throws a compiler error.
Describe the solution you'd like
When there is an Observer method in which i don't want to respond, I would like to omit that function from my conforming class. I would like to go from this...

...and remove the empty methods so it looks like this...

Describe alternatives you've considered
I currently have empty methods with a log or NO-OP comment.
Additional context
My first thought would be to add @objc optional prefix to the Observer protocol method definitions. However, this would cause anything that calls the observer functions to be updated to use some kind of optional chaining, which would possibly break backwards compatibility for some people. Opening this issue to see if there is any interest in a change like this being made, or maybe there is a workaround that allows for backwards compatibility.
Discussed @keverly about this. Since Chime mobile SDK was released to public for 6+ months and has been adopted by many customers already, we need to be cautions and try not to make breaking change. If we add @objc optional attribute to all the observer callbacks, customers need to use optional changing in all the classes that calls the observer callbacks.
One possible alternative may be to break down the large protocols into smaller ones. For example, we could break RealtimeObserver into VolumeObserver, SignalStrengthObserver and AttendeeStatusObserver protocols. RealtimeObserver will adapts these three sub-protocols so that existing customers' code won't break, and new customers can adapt the sub-protocols for a fine-grained control. However, this will not solve the example issue @keverly mentioned above.
We'll keep this issue open and see if there is any interest from other builders. Added enhancement label.