easy-eventbus
Advanced tools
Comparing version 0.2.8 to 0.2.9
{ | ||
"name": "easy-eventbus", | ||
"version": "0.2.8", | ||
"version": "0.2.9", | ||
"description": "this is a library for eventbus", | ||
@@ -53,6 +53,7 @@ "main": "index.js", | ||
"node-sass": "^4.8.3", | ||
"ora": "^3.0.0", | ||
"sass-loader": "^6.0.7", | ||
"style-loader": "^0.20.3", | ||
"uglifyjs-webpack-plugin": "^1.2.4", | ||
"webpack": "^4.4.1", | ||
"webpack": "^4.19.0", | ||
"webpack-cli": "^2.0.13", | ||
@@ -64,5 +65,5 @@ "webpack-dev-server": "^3.1.1" | ||
"ts-loader": "^5.3.2", | ||
"typescript": "^3.2.2" | ||
"typescript": "^3.1.2" | ||
}, | ||
"pluginName": "eventBus" | ||
} |
@@ -28,3 +28,3 @@ /** | ||
*/ | ||
const _addListener = function(type: string, fn: Function) { | ||
const _addListener = function(this: eventbus.subscriber, type: string, fn: Function) { | ||
// 判断有没有重复的,有就覆盖 | ||
@@ -57,3 +57,3 @@ let index = 0 | ||
*/ | ||
const _removeListener = function(type: string) { | ||
const _removeListener = function(this: eventbus.subscriber, type: string) { | ||
this.listeners = this.listeners.filter((v: eventbus.listener) => v.type !== type) | ||
@@ -67,3 +67,3 @@ } | ||
*/ | ||
const _removeAllListener = function(type: string) { | ||
const _removeAllListener = function(this: eventbus.subscriber) { | ||
this.listeners = [] | ||
@@ -75,3 +75,3 @@ } | ||
*/ | ||
const _getListener = function() { | ||
const _getListener = function(this: eventbus.subscriber) { | ||
return this.listeners | ||
@@ -108,3 +108,3 @@ } | ||
*/ | ||
createSubscriber = function() { | ||
createSubscriber = function(this: any) { | ||
this.count += 1 | ||
@@ -138,3 +138,3 @@ // 派发事件 | ||
*/ | ||
$emit = function(type: string, ...args: any[]) { | ||
$emit = function (this: any, type: string, ...args: any[]) { | ||
this.subscribers.forEach((v: eventbus.subscriber) => { | ||
@@ -146,2 +146,3 @@ v.listeners.some((v: eventbus.listener) => { | ||
} | ||
return false | ||
}) | ||
@@ -158,3 +159,3 @@ }) | ||
*/ | ||
dispatch = function(type: string, ...args: any[]) { | ||
dispatch = function (this: any, type: string, ...args: any[]) { | ||
this.$emit(type, ...args) | ||
@@ -169,3 +170,3 @@ } | ||
*/ | ||
removeSubscriber = function(id: number) { | ||
removeSubscriber = function (this: any, id: number) { | ||
return this.subscribers.some((v: eventbus.subscriber, i: number) => { | ||
@@ -187,3 +188,3 @@ if (v.id === id) { | ||
*/ | ||
removeAllSubscriber = function() { | ||
removeAllSubscriber = function (this: any) { | ||
this.count = 0 | ||
@@ -200,3 +201,3 @@ this.subscribers = [] | ||
*/ | ||
getSubscriber = function(id: number) { | ||
getSubscriber = function (this: any, id: number) { | ||
if (id) { | ||
@@ -203,0 +204,0 @@ return this.subscribers.filter((v: eventbus.subscriber) => v.id === id)[0] |
111426
1529
36
Updatedtypescript@^3.1.2