mm_expand 2.1.8 → 2.1.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/lib/base.js +13 -13
- package/package.json +1 -1
package/lib/base.js
CHANGED
|
@@ -15,7 +15,7 @@ class Base extends Event {
|
|
|
15
15
|
* 状态
|
|
16
16
|
* @type {string} - 状态, 可选值: creating, created, initing, inited, loading, loaded, starting, running, stopping, stopped, unloading, unloaded, destroying, destroyed
|
|
17
17
|
*/
|
|
18
|
-
#
|
|
18
|
+
#state = 'creating';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* 构造函数
|
|
@@ -39,16 +39,16 @@ class Base extends Event {
|
|
|
39
39
|
* 获取当前状态
|
|
40
40
|
* @returns {string} 当前状态
|
|
41
41
|
*/
|
|
42
|
-
|
|
43
|
-
return this.#
|
|
42
|
+
getState() {
|
|
43
|
+
return this.#state;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* 设置当前状态
|
|
48
|
-
* @param {string}
|
|
48
|
+
* @param {string} state 状态
|
|
49
49
|
*/
|
|
50
|
-
|
|
51
|
-
this.#
|
|
50
|
+
setState(state) {
|
|
51
|
+
this.#state = state;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -66,11 +66,11 @@ Base.prototype._listen = function () {
|
|
|
66
66
|
Base.prototype._onInit = function () {
|
|
67
67
|
// 初始化
|
|
68
68
|
this.on('init:before', async (ctx) => {
|
|
69
|
-
this.
|
|
69
|
+
this.setState('initing');
|
|
70
70
|
await this._initCore(...ctx.params);
|
|
71
71
|
});
|
|
72
72
|
this.on('init:after', (ctx) => {
|
|
73
|
-
this.
|
|
73
|
+
this.setState('inited');
|
|
74
74
|
});
|
|
75
75
|
};
|
|
76
76
|
|
|
@@ -78,20 +78,20 @@ Base.prototype._onInit = function () {
|
|
|
78
78
|
* 监听销毁事件
|
|
79
79
|
*/
|
|
80
80
|
Base.prototype._onDestroy = function () {
|
|
81
|
-
let
|
|
81
|
+
let state_last = 'stopped';
|
|
82
82
|
// 销毁
|
|
83
83
|
this.on('destroy:before', async (ctx) => {
|
|
84
|
-
|
|
85
|
-
this.
|
|
84
|
+
state_last = this.getState();
|
|
85
|
+
this.setState('destroying');
|
|
86
86
|
});
|
|
87
87
|
this.on('destroy:after', async (ctx) => {
|
|
88
88
|
await this._destroyCore(...ctx.params);
|
|
89
89
|
});
|
|
90
90
|
this.on('destroy:success', (ctx) => {
|
|
91
|
-
this.
|
|
91
|
+
this.setState('destroyed');
|
|
92
92
|
});
|
|
93
93
|
this.on('destroy:error', (ctx) => {
|
|
94
|
-
this.
|
|
94
|
+
this.setState(state_last);
|
|
95
95
|
});
|
|
96
96
|
};
|
|
97
97
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_expand",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.9",
|
|
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": {
|