@lijuhong1981/jsevents 1.2.7 → 1.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +26 -26
- package/src/EventDispatcher.js +5 -2
- package/src/EventEmitter.js +6 -0
- package/src/EventSubscriber.js +3 -0
package/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@lijuhong1981/jsevents",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "> TODO: description",
|
|
5
|
-
"author": "lijuhong1981 <lijuhong@hotmail.com>",
|
|
6
|
-
"homepage": "https://github.com/lijuhong1981/jslibs#readme",
|
|
7
|
-
"license": "ISC",
|
|
8
|
-
"type": "module",
|
|
9
|
-
"main": "index.js",
|
|
10
|
-
"module": "index.js",
|
|
11
|
-
"publishConfig": {
|
|
12
|
-
"access": "public"
|
|
13
|
-
},
|
|
14
|
-
"repository": {
|
|
15
|
-
"type": "git",
|
|
16
|
-
"url": "git+https://github.com/lijuhong1981/jslibs.git"
|
|
17
|
-
},
|
|
18
|
-
"bugs": {
|
|
19
|
-
"url": "https://github.com/lijuhong1981/jslibs/issues"
|
|
20
|
-
},
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"@lijuhong1981/jscheck": "^1.1.
|
|
23
|
-
"@lijuhong1981/jsdestroy": "^1.2.5"
|
|
24
|
-
},
|
|
25
|
-
"gitHead": "
|
|
26
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@lijuhong1981/jsevents",
|
|
3
|
+
"version": "1.2.9",
|
|
4
|
+
"description": "> TODO: description",
|
|
5
|
+
"author": "lijuhong1981 <lijuhong@hotmail.com>",
|
|
6
|
+
"homepage": "https://github.com/lijuhong1981/jslibs#readme",
|
|
7
|
+
"license": "ISC",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "index.js",
|
|
10
|
+
"module": "index.js",
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/lijuhong1981/jslibs.git"
|
|
17
|
+
},
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/lijuhong1981/jslibs/issues"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@lijuhong1981/jscheck": "^1.1.4",
|
|
23
|
+
"@lijuhong1981/jsdestroy": "^1.2.5"
|
|
24
|
+
},
|
|
25
|
+
"gitHead": "0aa8a09a9c5bc3ad3fd3710892adf1efb223e5a6"
|
|
26
|
+
}
|
package/src/EventDispatcher.js
CHANGED
|
@@ -5,12 +5,12 @@ import Destroyable from "@lijuhong1981/jsdestroy/src/Destroyable.js";
|
|
|
5
5
|
import Event from "./EventSubscriber.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Description
|
|
9
8
|
* @param {Map<any, Event>} events
|
|
10
9
|
* @param {any} type
|
|
11
10
|
* @param {Function} callback
|
|
12
11
|
* @param {object} options
|
|
13
12
|
* @returns {void}
|
|
13
|
+
* @private
|
|
14
14
|
*/
|
|
15
15
|
function addListener(events, type, callback, options) {
|
|
16
16
|
let event = events.get(type);
|
|
@@ -22,11 +22,11 @@ function addListener(events, type, callback, options) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* Description
|
|
26
25
|
* @param {Map<any, Event>} events
|
|
27
26
|
* @param {any} type
|
|
28
27
|
* @param {Function} callback
|
|
29
28
|
* @returns {void}
|
|
29
|
+
* @private
|
|
30
30
|
*/
|
|
31
31
|
function removeListener(events, type, callback) {
|
|
32
32
|
const event = events.get(type);
|
|
@@ -42,6 +42,9 @@ function removeListener(events, type, callback) {
|
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* 事件分发管理器
|
|
45
|
+
*
|
|
46
|
+
* @class EventDispatcher
|
|
47
|
+
* @extends Destroyable
|
|
45
48
|
*/
|
|
46
49
|
class EventDispatcher extends Destroyable {
|
|
47
50
|
constructor() {
|
package/src/EventEmitter.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import Destroyable from "@lijuhong1981/jsdestroy/src/Destroyable.js";
|
|
2
2
|
import EventDispatcher from "./EventDispatcher.js";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* 事件发射器
|
|
6
|
+
*
|
|
7
|
+
* @class EventEmitter
|
|
8
|
+
* @extends Destroyable
|
|
9
|
+
*/
|
|
4
10
|
class EventEmitter extends Destroyable {
|
|
5
11
|
constructor() {
|
|
6
12
|
super();
|
package/src/EventSubscriber.js
CHANGED
|
@@ -3,6 +3,9 @@ import Destroyable from "@lijuhong1981/jsdestroy/src/Destroyable.js";
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A generic utility class for managing subscribers for a particular event. This class is usually instantiated inside of a container class and exposed as a property for others to subscribe to.
|
|
6
|
+
*
|
|
7
|
+
* @class EventSubscriber
|
|
8
|
+
* @extends Destroyable
|
|
6
9
|
*/
|
|
7
10
|
class EventSubscriber extends Destroyable {
|
|
8
11
|
constructor() {
|