Overall, I'm happy to see this being pitched. I'm encouraged to see that the requirement for a synchronous solution to observation has been recognised. Clearly, the approach taken must bridge the old world to the new and therefore it necessities a bunch of boilerplate.
However, it's striking to re-observe that we still don't have a synchronous observation mechanism that is Swift-first in its approach. I remember initial discussions where asynchronous sequences were promoted in this role, but given that an asynchronous sequence is, well, asynchronous, it seems like we've all realised that trying to make them synchronous would be beating a round peg into a square hole. This pitch seems like recognition of this.
With that in mind, if we did have a Swift-first observation mechanism, would the approach taken to bridge the new and the old be slightly different? Or, are we saying that NotificationCenter is now the officially blessed tool for one-to-many synchronous observation?
In this role, with the level of boilerplate required, I think its charm is more limited. Instead, I'd rather see a Swift-first solution, so I hope the realisation of this 'bridging' proposal doesn't delay its arrival.
Drilling down a bit:
addObserver(_:observer:)
What wasn't quite clear to me in the pitch was observation cancellation. On the one hand the pitch says:
[addObserver(_:observer:)] also return[s] a new ObservationToken, which can be used with a new removeObserver() method for faster de-registration of observers
Which suggests that the return value can be ignored, but if that was the case the method should probably be annotated with @discardableResult. And, If the return value can safely be ignored, albeit with an 'slower' de-registration, what exactly does that look like?
ObservationToken
The pitch says that observations can be ended by calling removeObserver(). Is this the only way to end observation, or can observations be removed automatically when an ObservationToken is deinited?