Xamarin: Cross-Platform Mobile Application Development
by Jonathan Peppers, George Taskos, Can Bilgin
Using the event messenger
When writing C# code, we rely a lot on instance events. A class might have some events that another class instance can register a handler and get notified when something happened; for example, classes that implement the INotifyPropertyChanged interface raise the PropertyChanged event when a property value is changed, or maybe we start a lengthy asynchronous task in another thread from a component we reference and we want to get notified about the progress. It's a great feature, but to make use of events the component that hooks to an instance event of another component must depend on it. Imagine if we have many cases of this communication: we will end up with spaghetti code and dependency references from component to ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access