© Dmitri Nesteruk 2019
Dmitri NesterukDesign Patterns in .NEThttps://doi.org/10.1007/978-1-4842-4366-4_21

21. Observer

Dmitri Nesteruk1 
(1)
St. Petersburg, c.St-Peterburg, Russia
 

The Observer pattern, quite simply, lets one component notify other components that something has happened. The pattern is used all over the place; for example, when binding data to the UI, we can program domain objects such that, when they change, they generate notifications that the UI can subscribe to and update the visuals.

The Observer pattern is a popular and necessary pattern, so it is not surprising that the designers of C# decided to incorporate the pattern into the language wholesale with the use of the event keyword . The use of events in C# typically uses a convention ...

Get Design Patterns in .NET: Reusable Approaches in C# and F# for Object-Oriented Software Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.