In the event-driven model, a main loop is generated to monitor events, and a callback function is triggered when an event is detected.
Functions are tasks that need to be performed. Event monitoring means to prepare a function (method) for a certain event, and execute the function if the event is triggered, for example: xxx.onclick = fn. Use fn to monitor onclick.
let fs = require('fs')
let events = require('event')
// 创建事件对象
var eventLog = new events.EventEmitter();
//监听事件
eventLog.on(lcMkDir,function(msg){
console.log('创建目录事件触发',msg)
})
//也可多任务
eventLog.on(lcMkDir,function(msg){
console.log('创建目录事件触发2',msg)
})eventLog.on(lcMkDir,function(msg){
console.log('创建目录事件触发3',msg)
})
//触发事件
eventLog.emit("lcMKDir","真的触发了!")
console.log('over')