Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Part 3: Programming Patterns > Provider/Subscriber Pattern

Chapter 18. Provider/Subscriber Pattern

The provider/subscriber pattern defines a one-to-many, unidirectional flow of information from a provider object to any number of subscriber objects. The concept is that the provider has useful information or events that need to be communicated to other objects, its subscribers, which will use that information to perform additional actions or stay in synchronization with the provider. In Java parlance, the provider fires notifications to its listeners. In Objective-C terminology, the provider posts notifications to its observers.

The provider/subscriber pattern is used heavily in Java, but Java doesn't provide any intrinsic service for helping objects manage their subscribers or coordinate messages. Consequently, most Java objects implement their own subscriber management. This isn't terribly difficult, but it does impose an important limitation: the provider and subscribers must have references to each other. Objective-C strongly encourages the provider/subscriber pattern by providing systemwide services for managing a provider's subscribers and delivering notifications to them. By providing intermediate management, providers and observers (subscribers) might know everything about each other, or nearly nothing at all.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial