DASHA
This commit is contained in:
		
							
								
								
									
										17
									
								
								События/app.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								События/app.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| const EventEmitter = require('events'); | ||||
|  | ||||
| let eventName = 'greet'; | ||||
|  | ||||
| class User extends EventEmitter { | ||||
|     sayHi(data) { | ||||
|         this.emit(eventName, data); | ||||
|     } | ||||
| } | ||||
|  | ||||
| let user = new User(); | ||||
| // добавляем к объекту user обработку события "greet" | ||||
| user.on(eventName, function (data) { | ||||
|     console.log(data); | ||||
| }); | ||||
|  | ||||
| user.sayHi('Мне нужна твоя одежда...'); | ||||
		Reference in New Issue
	
	Block a user
	 User1
					User1