mm_expand 2.1.1 → 2.1.2
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/lib/base.js +16 -5
- package/package.json +1 -1
package/lib/base.js
CHANGED
|
@@ -26,13 +26,16 @@ class Base extends Event {
|
|
|
26
26
|
*/
|
|
27
27
|
this.status = 'creating';
|
|
28
28
|
|
|
29
|
-
// 初始化监听
|
|
30
|
-
this._initListen();
|
|
31
29
|
// 设置配置
|
|
32
30
|
this.setConfig(config);
|
|
33
31
|
|
|
34
32
|
// 状态变更为 created 已完成
|
|
35
33
|
this.status = 'created';
|
|
34
|
+
|
|
35
|
+
// 监听初始化事件
|
|
36
|
+
this._onInit();
|
|
37
|
+
// 监听销毁事件
|
|
38
|
+
this._onDestroy();
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
41
|
|
|
@@ -47,10 +50,9 @@ Base.prototype.log = function (level, message, ...params) {
|
|
|
47
50
|
};
|
|
48
51
|
|
|
49
52
|
/**
|
|
50
|
-
*
|
|
53
|
+
* 监听初始化事件
|
|
51
54
|
*/
|
|
52
|
-
Base.prototype.
|
|
53
|
-
let status_last = 'created';
|
|
55
|
+
Base.prototype._onInit = function () {
|
|
54
56
|
// 初始化
|
|
55
57
|
this.on('init:before', async (ctx) => {
|
|
56
58
|
this.status = 'initing';
|
|
@@ -59,10 +61,19 @@ Base.prototype._initListen = function () {
|
|
|
59
61
|
this.on('init:after', (ctx) => {
|
|
60
62
|
this.status = 'inited';
|
|
61
63
|
});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 监听销毁事件
|
|
68
|
+
*/
|
|
69
|
+
Base.prototype._onDestroy = function () {
|
|
70
|
+
let status_last = 'created';
|
|
62
71
|
// 销毁
|
|
63
72
|
this.on('destroy:before', async (ctx) => {
|
|
64
73
|
status_last = this.status;
|
|
65
74
|
this.status = 'destroying';
|
|
75
|
+
});
|
|
76
|
+
this.on('destroy:after', async (ctx) => {
|
|
66
77
|
await this._destroyCore(...ctx.params);
|
|
67
78
|
});
|
|
68
79
|
this.on('destroy:success', (ctx) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_expand",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "Super Meimei Prototype Function Extension Module - Enhanced operations for string, array, object, date manipulation with error prevention and simplified business logic.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|