Hi @icanzilb, thank you for your thoughtful and historical reply…it makes sense if the language evolved from subscribing to events on an observable/publisher.
The following is a little off topic, but I think it serves to illustrate the benefits of learning Combine, from what I understand after only two chapters!
My experience with observables coming into this book is with Smalltalk, the latest incarnation being the Announcements framework.
There, you create a subclass of an Announcement, which I guess is sort of like the Input typealias in a custom Subscriber. It can hold specific information about the announcement.
Then, an observable object will [usually] create and hold on to an Announcer subclass. I guess you might have a global Announcer like NotificationCenter.
Finally, an observer listens for specific announcement class with either:
-
when: anAnnouncementClass do: aValuable : when anAnnouncementClass is raised, aValuable is executed.
-
when: anAnnouncementClass do: aValuable for: aSubscriber: when anAnnouncementClass is raised, aValuable is executed and define the subscriber.
-
when: anAnnouncementClass send: aSelector to: anObject: when anAnnouncementClass is raised, anObject should receive the message aSelector.
In other words, the simplest version would be something like:
Announcement subclass: #MyAnnouncement
instanceVariableNames: ''
classVariableNames: ''
package: ''.
announcer := Announcer new.
aSubscription := announcer when: MyAnnouncement do: [ Transcript show: 'Announcement received.' ].
announcement := MyAnnouncement new.
announcer announce: announcement.
As you can see, it is really very basic and doesn’t have any of the built-in chaining, streaming, completion, error handling, etc… that is present in Combine, so I am really looking forward to learning more from your book.
In then end, if I am bothered by it, I can always create a Subscriber extension that will turn around and connect to the publisher properly so my mind quits bending!
Thanks again!