Commit 0f076091 by hank

修复event tslint

parent 4241bbb7
......@@ -21,6 +21,7 @@
"dev:tt": "npm run build:tt -- --watch",
"dev:h5": "npm run build:h5 -- --watch",
"dev:rn": "npm run build:rn -- --watch",
"precommit": "npm run lint",
"lint": "tslint --project ./tsconfig.json && stylelint \"./src/**/*.scss\"",
"run:shell": "cd ../taro-native-shell/ && yarn android"
},
......
// tslint:disable:no-invalid-this
// tslint:disable-next-line:only-arrow-functions
const EventBus = (function() {
function EventBusClass() {
this.msgQueues = {}
......@@ -18,6 +20,7 @@ const EventBus = (function() {
// 消息队列中仅保存一个消息
one: function(msgName, func) {
// 无需检查msgName是否存在
this.msgQueues[msgName] = func
},
// 发送消息
......@@ -25,6 +28,7 @@ const EventBus = (function() {
if (!this.msgQueues.hasOwnProperty(msgName)) {
return
}
if (typeof this.msgQueues[msgName] === 'function') {
this.msgQueues[msgName](msg)
} else {
......@@ -39,11 +43,12 @@ const EventBus = (function() {
if (!this.msgQueues.hasOwnProperty(msgName)) {
return
}
delete this.msgQueues[msgName]
}
}
var EventBus = new EventBusClass()
return EventBus
let Event = new EventBusClass()
return Event
})()
export default EventBus
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment