Skip to content

Commit e5b8d05

Browse files
authored
Update README.md
1 parent 5707ad7 commit e5b8d05

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

README.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,14 @@ ReadOnlyObservableCollection<MostRecentlyUsedFileItem> mruList = mruManager.Most
348348

349349
----
350350
### `EventAggregator`
351-
Dynamic implementation of the EventAggregator design pattern. Listen to events broadcasted by a specific type or by a specific event or by matching event handler signature.
351+
Dynamic implementation of the EventAggregator design pattern.
352+
Listen to broadcasted events by a specific source type, by a specific event name, by matching event handler signature or by matching `EventArgs` type.
353+
352354
Allows to listen to an event without the need to reference the source instance.
353355

354356
#### Example
355357
##### Aggregate events
356-
Let the `EventAggregator` subscribe to events:
358+
Register event sources with an instance of `EventAggregator`:
357359

358360
```C#
359361
var aggregator = new EventAggregator();
@@ -379,8 +381,8 @@ aggregator.TryRegisterObservable(
379381
new[] {nameof(INotifyPropertyChanged.PropertyChanged)});
380382
```
381383

382-
##### Listen to *all* aggregated event sources *by event name*
383-
Subscribe to the `EventAggregator` and listen to specific events of **all** aggregated event sources:
384+
##### Listen to events by name, raised by any aggregated event source
385+
Subscribe to the `EventAggregator` and listen to **specific events** of **all event sources**:
384386

385387
```C#
386388
// Listen to everything that publishes the 'INotifyPropertyChanged.PropertyChanged' event
@@ -389,8 +391,8 @@ aggregator.TryRegisterObserver<PropertyChangedEventHandler>(
389391
ShowMessage_OnPropertyChanged);
390392
```
391393

392-
##### Listen to *specific* aggregated event sources by event name
393-
Subscribe to the `EventAggregator` and listen to specific events of **specific** aggregated event sources (by source type):
394+
##### Listen to events by name, raised by all event sources that match a specific type (e.g., class or interface)
395+
Subscribe to the `EventAggregator` and listen to **specific events** of **specific event sources** (by source type):
394396

395397
```C#
396398
// Only listen to the 'INotifyPropertyChanged.PropertyChanged' event raised by any instance of type 'MainWindowViewModel'
@@ -399,29 +401,30 @@ aggregator.TryRegisterObserver<PropertyChangedEventHandler>(
399401
mainWindowViewModel.GetType(),
400402
ShowMessage_OnPropertyChanged);
401403

402-
// Only listen to the 'INotifyPropertyChanged.PropertyChanged' event of all instances that implement 'IPage'
404+
// Only listen to the 'INotifyPropertyChanged.PropertyChanged' event of all instances that implement 'IPage' interface
403405
aggregator.TryRegisterObserver<PropertyChangedEventHandler>(
404406
nameof(INotifyPropertyChanged.PropertyChanged),
405407
typeof(IPage),
406408
ShowMessage_OnPropertyChanged);
409+
407410
```
408411
##### Listen to all events that match the signature of the event handler or that use a matching `EventArgs` type
409412

410-
Subscribe to the `EventAggregator` and listen to all events that have an event delegate with matching signature:
413+
Subscribe to the `EventAggregator` and listen to all events that have an **event delegate with matching signature**:
411414
```C#
412415

413416
// Subscribe by defining the event delegate explicitly
414417
aggregator.TryRegisterGlobalObserver(new PropertyChangedEventHandler(ShowMessage_OnPropertyChanged));
415418
```
416419

417-
Subscribe to the `EventAggregator` and listen to all events that use a matching `EventArgs` type:
420+
Subscribe to the `EventAggregator` and listen to all events that use a **matching `EventArgs` type**:
418421

419422
```C#
420423
// Subscribe by defining the EventArgs as generic type parameter
421424
aggregator.TryRegisterGlobalObserver<PropertyChangedEventArgs>(ShowMessage_OnPropertyChanged);
422425
```
423426
424-
##### Type declarations used in examples
427+
##### Type declarations used in above examples
425428

426429
```C#
427430
// Event callback

0 commit comments

Comments
 (0)