mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	
		
			
	
	
		
			24 lines
		
	
	
		
			560 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
		
		
			
		
	
	
			24 lines
		
	
	
		
			560 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
|  | export default class Component { | ||
|  |     /** @param {AppContext} appContext */ | ||
|  |     constructor(appContext) { | ||
|  |         this.appContext = appContext; | ||
|  |         /** @type Component[] */ | ||
|  |         this.children = []; | ||
|  |     } | ||
|  | 
 | ||
|  |     eventReceived(name, data) { | ||
|  |         const fun = this[name + 'Listener']; | ||
|  | 
 | ||
|  |         if (typeof fun === 'function') { | ||
|  |             fun.call(this, data); | ||
|  |         } | ||
|  | 
 | ||
|  |         for (const child of this.children) { | ||
|  |             child.eventReceived(name, data); | ||
|  |         } | ||
|  |     } | ||
|  | 
 | ||
|  |     trigger(name, data) { | ||
|  |         this.appContext.trigger(name, data); | ||
|  |     } | ||
|  | } |