| 
									
										
										
										
											2015-08-13 23:54:40 +02:00
										 |  |  | --- | 
					
						
							|  |  |  | layout: pattern | 
					
						
							|  |  |  | title: Event Aggregator | 
					
						
							|  |  |  | folder: event-aggregator | 
					
						
							| 
									
										
										
										
											2015-08-15 18:03:05 +02:00
										 |  |  | permalink: /patterns/event-aggregator/ | 
					
						
							| 
									
										
										
										
											2015-08-20 21:40:07 +02:00
										 |  |  | categories: Structural | 
					
						
							| 
									
										
										
										
											2015-12-28 15:52:44 +02:00
										 |  |  | tags: | 
					
						
							| 
									
										
										
										
											2016-07-21 09:27:48 +03:00
										 |  |  |  - Reactive | 
					
						
							| 
									
										
										
										
											2015-08-13 23:54:40 +02:00
										 |  |  | --- | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-03 21:14:30 +01:00
										 |  |  | ## Intent
 | 
					
						
							|  |  |  | A system with lots of objects can lead to complexities when a | 
					
						
							| 
									
										
										
										
											2015-08-13 23:54:40 +02:00
										 |  |  | client wants to subscribe to events. The client has to find and register for | 
					
						
							|  |  |  | each object individually, if each object has multiple events then each event | 
					
						
							|  |  |  | requires a separate subscription. An Event Aggregator acts as a single source | 
					
						
							|  |  |  | of events for many objects. It registers for all the events of the many objects | 
					
						
							|  |  |  | allowing clients to register with just the aggregator. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-07 20:01:13 +02:00
										 |  |  | ## Class diagram
 | 
					
						
							| 
									
										
										
										
											2015-08-13 23:54:40 +02:00
										 |  |  |  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-03 21:14:30 +01:00
										 |  |  | ## Applicability
 | 
					
						
							|  |  |  | Use the Event Aggregator pattern when | 
					
						
							| 
									
										
										
										
											2015-08-13 23:54:40 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | * Event Aggregator is a good choice when you have lots of objects that are | 
					
						
							|  |  |  |   potential event sources. Rather than have the observer deal with registering | 
					
						
							|  |  |  |   with them all, you can centralize the registration logic to the Event | 
					
						
							|  |  |  |   Aggregator. As well as simplifying registration, a Event Aggregator also | 
					
						
							| 
									
										
										
										
											2015-08-15 18:03:05 +02:00
										 |  |  |   simplifies the memory management issues in using observers. | 
					
						
							| 
									
										
										
										
											2015-09-03 18:17:07 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-03 21:14:30 +01:00
										 |  |  | ## Credits
 | 
					
						
							| 
									
										
										
										
											2015-09-03 18:17:07 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | * [Martin Fowler - Event Aggregator](http://martinfowler.com/eaaDev/EventAggregator.html) |