@gby/destroyable 1.0.0

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.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +101 -0
  3. package/dist/Destroyable.d.ts +257 -0
  4. package/dist/Destroyable.d.ts.map +1 -0
  5. package/dist/DestroyableSub.d.ts +67 -0
  6. package/dist/DestroyableSub.d.ts.map +1 -0
  7. package/dist/createDestroyableSubClass.d.ts +82 -0
  8. package/dist/createDestroyableSubClass.d.ts.map +1 -0
  9. package/dist/index.d.ts +12 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +229 -0
  12. package/dist/index.umd.cjs +1 -0
  13. package/dist/tsdoc-metadata.json +11 -0
  14. package/doc/api/destroyable.createdestroyablesubclass.md +76 -0
  15. package/doc/api/destroyable.destroyable._destroyers.md +13 -0
  16. package/doc/api/destroyable.destroyable._isdestroyed.md +11 -0
  17. package/doc/api/destroyable.destroyable.canceldispose.md +49 -0
  18. package/doc/api/destroyable.destroyable.canceldispose_1.md +49 -0
  19. package/doc/api/destroyable.destroyable.canceldispose_2.md +49 -0
  20. package/doc/api/destroyable.destroyable.canceldisposefun.md +52 -0
  21. package/doc/api/destroyable.destroyable.canceldisposeobj.md +52 -0
  22. package/doc/api/destroyable.destroyable.destroy.md +17 -0
  23. package/doc/api/destroyable.destroyable.destroyasync.md +21 -0
  24. package/doc/api/destroyable.destroyable.destroythis.md +21 -0
  25. package/doc/api/destroyable.destroyable.dispose.md +51 -0
  26. package/doc/api/destroyable.destroyable.dispose_1.md +65 -0
  27. package/doc/api/destroyable.destroyable.dispose_2.md +65 -0
  28. package/doc/api/destroyable.destroyable.disposefun.md +53 -0
  29. package/doc/api/destroyable.destroyable.disposeobj.md +68 -0
  30. package/doc/api/destroyable.destroyable.isdestroyed.md +13 -0
  31. package/doc/api/destroyable.destroyable.md +287 -0
  32. package/doc/api/destroyable.destroyablesub.md +15 -0
  33. package/doc/api/destroyable.destroyablesubclass.md +13 -0
  34. package/doc/api/destroyable.destroydestroyable.md +52 -0
  35. package/doc/api/destroyable.destroyobject.md +52 -0
  36. package/doc/api/destroyable.fundestroyer.md +13 -0
  37. package/doc/api/destroyable.md +225 -0
  38. package/doc/api/destroyable.nodedestroyable.md +33 -0
  39. package/doc/api/destroyable.nodedestroyableclass.md +15 -0
  40. package/doc/api/destroyable.throwondestroyed.md +17 -0
  41. package/doc/api/destroyable.webdestroyable.md +33 -0
  42. package/doc/api/destroyable.webdestroyableclass.md +15 -0
  43. package/doc/api/index.md +31 -0
  44. package/doc//346/225/231/347/250/213.md +7 -0
  45. package/package.json +72 -0
package/dist/index.js ADDED
@@ -0,0 +1,229 @@
1
+ var a = Object.defineProperty;
2
+ var l = (t, e, r) => e in t ? a(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
+ var o = (t, e, r) => l(t, typeof e != "symbol" ? e + "" : e, r);
4
+ import { EventBus as f } from "@gby/event-bus";
5
+ import { EventEmitter as p } from "node:events";
6
+ class _ {
7
+ constructor() {
8
+ o(this, "_isDestroyed", !1);
9
+ /**
10
+ * 销毁者
11
+ */
12
+ o(this, "_destroyers", []);
13
+ }
14
+ /**
15
+ * 是否已经销毁
16
+ */
17
+ get isDestroyed() {
18
+ return this._isDestroyed;
19
+ }
20
+ /**
21
+ * 添加销毁者
22
+ * @param fun
23
+ * @returns 返回销毁者的顺序
24
+ */
25
+ disposeFun(e) {
26
+ return this._destroyers.push(e), e;
27
+ }
28
+ /**
29
+ * 取消销毁者函数
30
+ * @param fun
31
+ * @returns
32
+ */
33
+ cancelDisposeFun(e) {
34
+ const r = this._destroyers.indexOf(e);
35
+ return this._destroyers.splice(r, 1), e;
36
+ }
37
+ /**
38
+ * 添加销毁对象
39
+ * @param obj
40
+ * @param sync - 表示是否使用 `obj.destroy()` 方法进行销毁;默认使用 `obj.destroyAsync()` 方法进行销毁
41
+ * @returns
42
+ */
43
+ disposeObj(e, r) {
44
+ const n = r ? function() {
45
+ return e.destroy();
46
+ } : function() {
47
+ return e.destroyAsync();
48
+ };
49
+ return this.disposeFun(n), e.__destroyable_destroyer = n, e;
50
+ }
51
+ /**
52
+ * 取消销毁者函数
53
+ * @param fun
54
+ * @returns
55
+ */
56
+ cancelDisposeObj(e) {
57
+ const r = e.__destroyable_destroyer;
58
+ return r && this.cancelDisposeFun(r), e;
59
+ }
60
+ dispose(e, r) {
61
+ return typeof e == "function" ? this.disposeFun(e) : this.disposeObj(e, r);
62
+ }
63
+ cancelDispose(e) {
64
+ return typeof e == "function" ? this.cancelDisposeFun(e) : this.cancelDisposeObj(e);
65
+ }
66
+ /**
67
+ * 自己的销毁方法
68
+ * @remarks
69
+ * 子类根据需要进行重载
70
+ */
71
+ destroyThis() {
72
+ }
73
+ /**
74
+ * 销毁
75
+ */
76
+ destroy() {
77
+ if (this.isDestroyed) return !0;
78
+ let e = this._destroyers.length;
79
+ for (; --e >= 0; )
80
+ try {
81
+ this._destroyers[e]();
82
+ } catch {
83
+ }
84
+ this._destroyers.length = 0, this.destroyThis(), u(this);
85
+ }
86
+ /**
87
+ * 异步销毁
88
+ * @remarks
89
+ * 会依次执行销毁,并且只有上一个销毁完成之后才会执行下一个销毁
90
+ */
91
+ async destroyAsync() {
92
+ if (this.isDestroyed) return !0;
93
+ let e = this._destroyers.length;
94
+ for (; --e >= 0; )
95
+ try {
96
+ await this._destroyers[e]();
97
+ } catch {
98
+ }
99
+ this._destroyers.length = 0, await this.destroyThis(), u(this);
100
+ }
101
+ }
102
+ function y() {
103
+ throw "已销毁";
104
+ }
105
+ function x(t) {
106
+ for (var e in t)
107
+ typeof t[e] == "function" && (t[e] = y);
108
+ return t._isDestroyed = !0, !0;
109
+ }
110
+ function u(t) {
111
+ for (var e in t)
112
+ !(e in _.prototype) && typeof t[e] == "function" && (t[e] = y);
113
+ return t._isDestroyed = !0, !0;
114
+ }
115
+ function c(t) {
116
+ class e extends t {
117
+ constructor() {
118
+ super(...arguments);
119
+ o(this, "_isDestroyed", !1);
120
+ /**
121
+ * 销毁者
122
+ */
123
+ o(this, "_destroyers", []);
124
+ }
125
+ /**
126
+ * 是否已经销毁
127
+ */
128
+ get isDestroyed() {
129
+ return this._isDestroyed;
130
+ }
131
+ /**
132
+ * 添加销毁者
133
+ * @param fun
134
+ * @returns 返回销毁者的顺序
135
+ */
136
+ disposeFun(s) {
137
+ return this._destroyers.push(s), s;
138
+ }
139
+ /**
140
+ * 取消销毁者函数
141
+ * @param fun
142
+ * @returns
143
+ */
144
+ cancelDisposeFun(s) {
145
+ const i = this._destroyers.indexOf(s);
146
+ return this._destroyers.splice(i, 1), s;
147
+ }
148
+ /**
149
+ * 添加销毁对象
150
+ * @param obj
151
+ * @param sync - 表示是否使用 `obj.destroy()` 方法进行销毁;默认使用 `obj.destroyAsync()` 方法进行销毁
152
+ * @returns
153
+ */
154
+ disposeObj(s, i) {
155
+ const h = i ? function() {
156
+ return s.destroy();
157
+ } : function() {
158
+ return s.destroyAsync();
159
+ };
160
+ return this.disposeFun(h), s.__destroyable_destroyer = h, s;
161
+ }
162
+ /**
163
+ * 取消销毁者函数
164
+ * @param fun
165
+ * @returns
166
+ */
167
+ cancelDisposeObj(s) {
168
+ const i = s.__destroyable_destroyer;
169
+ return i && this.cancelDisposeFun(i), s;
170
+ }
171
+ dispose(s, i) {
172
+ return typeof s == "function" ? this.disposeFun(s) : this.disposeObj(s, i);
173
+ }
174
+ cancelDispose(s) {
175
+ return typeof s == "function" ? this.cancelDisposeFun(s) : this.cancelDisposeObj(s);
176
+ }
177
+ /**
178
+ * 自己的销毁方法
179
+ * @remarks
180
+ * 子类根据需要进行重载
181
+ */
182
+ destroyThis() {
183
+ }
184
+ /**
185
+ * 销毁
186
+ */
187
+ destroy() {
188
+ if (this.isDestroyed) return !0;
189
+ let s = this._destroyers.length;
190
+ for (; --s >= 0; )
191
+ try {
192
+ this._destroyers[s]();
193
+ } catch {
194
+ }
195
+ this._destroyers.length = 0, this.destroyThis(), r(this);
196
+ }
197
+ /**
198
+ * 异步销毁
199
+ * @remarks
200
+ * 会依次执行销毁,并且只有上一个销毁完成之后才会执行下一个销毁
201
+ */
202
+ async destroyAsync() {
203
+ if (this.isDestroyed) return !0;
204
+ let s = this._destroyers.length;
205
+ for (; --s >= 0; )
206
+ try {
207
+ await this._destroyers[s]();
208
+ } catch {
209
+ }
210
+ this._destroyers.length = 0, await this.destroyThis(), r(this);
211
+ }
212
+ }
213
+ function r(n) {
214
+ for (var d in n)
215
+ !(d in e.prototype) && typeof n[d] == "function" && (n[d] = y);
216
+ return n._isDestroyed = !0, !0;
217
+ }
218
+ return e;
219
+ }
220
+ const T = c(f), m = c(p);
221
+ export {
222
+ _ as Destroyable,
223
+ m as NodeDestroyable,
224
+ T as WebDestroyable,
225
+ c as createDestroyableSubClass,
226
+ u as destroyDestroyable,
227
+ x as destroyObject,
228
+ y as throwOnDestroyed
229
+ };
@@ -0,0 +1 @@
1
+ (function(t,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@gby/event-bus"),require("node:events")):typeof define=="function"&&define.amd?define(["exports","@gby/event-bus","node:events"],r):(t=typeof globalThis<"u"?globalThis:t||self,r(t.Destroyable={},t.eventBus,t.node_events))})(this,function(t,r,y){"use strict";var g=Object.defineProperty;var v=(t,r,y)=>r in t?g(t,r,{enumerable:!0,configurable:!0,writable:!0,value:y}):t[r]=y;var u=(t,r,y)=>v(t,typeof r!="symbol"?r+"":r,y);class a{constructor(){u(this,"_isDestroyed",!1);u(this,"_destroyers",[])}get isDestroyed(){return this._isDestroyed}disposeFun(e){return this._destroyers.push(e),e}cancelDisposeFun(e){const i=this._destroyers.indexOf(e);return this._destroyers.splice(i,1),e}disposeObj(e,i){const d=i?function(){return e.destroy()}:function(){return e.destroyAsync()};return this.disposeFun(d),e.__destroyable_destroyer=d,e}cancelDisposeObj(e){const i=e.__destroyable_destroyer;return i&&this.cancelDisposeFun(i),e}dispose(e,i){return typeof e=="function"?this.disposeFun(e):this.disposeObj(e,i)}cancelDispose(e){return typeof e=="function"?this.cancelDisposeFun(e):this.cancelDisposeObj(e)}destroyThis(){}destroy(){if(this.isDestroyed)return!0;let e=this._destroyers.length;for(;--e>=0;)try{this._destroyers[e]()}catch{}this._destroyers.length=0,this.destroyThis(),f(this)}async destroyAsync(){if(this.isDestroyed)return!0;let e=this._destroyers.length;for(;--e>=0;)try{await this._destroyers[e]()}catch{}this._destroyers.length=0,await this.destroyThis(),f(this)}}function h(){throw"已销毁"}function D(n){for(var e in n)typeof n[e]=="function"&&(n[e]=h);return n._isDestroyed=!0,!0}function f(n){for(var e in n)!(e in a.prototype)&&typeof n[e]=="function"&&(n[e]=h);return n._isDestroyed=!0,!0}function l(n){class e extends n{constructor(){super(...arguments);u(this,"_isDestroyed",!1);u(this,"_destroyers",[])}get isDestroyed(){return this._isDestroyed}disposeFun(s){return this._destroyers.push(s),s}cancelDisposeFun(s){const o=this._destroyers.indexOf(s);return this._destroyers.splice(o,1),s}disposeObj(s,o){const p=o?function(){return s.destroy()}:function(){return s.destroyAsync()};return this.disposeFun(p),s.__destroyable_destroyer=p,s}cancelDisposeObj(s){const o=s.__destroyable_destroyer;return o&&this.cancelDisposeFun(o),s}dispose(s,o){return typeof s=="function"?this.disposeFun(s):this.disposeObj(s,o)}cancelDispose(s){return typeof s=="function"?this.cancelDisposeFun(s):this.cancelDisposeObj(s)}destroyThis(){}destroy(){if(this.isDestroyed)return!0;let s=this._destroyers.length;for(;--s>=0;)try{this._destroyers[s]()}catch{}this._destroyers.length=0,this.destroyThis(),i(this)}async destroyAsync(){if(this.isDestroyed)return!0;let s=this._destroyers.length;for(;--s>=0;)try{await this._destroyers[s]()}catch{}this._destroyers.length=0,await this.destroyThis(),i(this)}}function i(d){for(var c in d)!(c in e.prototype)&&typeof d[c]=="function"&&(d[c]=h);return d._isDestroyed=!0,!0}return e}const _=l(r.EventBus),b=l(y.EventEmitter);t.Destroyable=a,t.NodeDestroyable=b,t.WebDestroyable=_,t.createDestroyableSubClass=l,t.destroyDestroyable=f,t.destroyObject=D,t.throwOnDestroyed=h,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.52.8"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,76 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@gby/destroyable](./destroyable.md) &gt; [createDestroyableSubClass](./destroyable.createdestroyablesubclass.md)
4
+
5
+ ## createDestroyableSubClass() function
6
+
7
+ 创建可销毁的子类
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export declare function createDestroyableSubClass<P extends new (...args: any) => any>(ParentClass: P): {
13
+ new (...args: any): {
14
+ [x: string]: any;
15
+ readonly isDestroyed: boolean;
16
+ _isDestroyed: boolean;
17
+ _destroyers: FunDestroyer[];
18
+ disposeFun<T extends FunDestroyer>(fun: T): T;
19
+ cancelDisposeFun<T extends FunDestroyer>(fun: T): T;
20
+ disposeObj<T extends /*elided*/ any>(obj: T, sync?: boolean): T;
21
+ cancelDisposeObj<T extends /*elided*/ any>(obj: T): T;
22
+ dispose<T extends FunDestroyer>(fun: T): T;
23
+ dispose<T extends /*elided*/ any>(obj: T, asyncDestroy?: boolean): T;
24
+ dispose<T extends /*elided*/ any | FunDestroyer>(objOrFun: T, asyncDestroy?: boolean): T;
25
+ cancelDispose<T extends FunDestroyer>(fun: T): T;
26
+ cancelDispose<T extends /*elided*/ any>(obj: T): T;
27
+ cancelDispose<T extends /*elided*/ any | FunDestroyer>(objOrFun: T): T;
28
+ destroyThis(): void;
29
+ destroy(): true | undefined;
30
+ destroyAsync(): Promise<true | undefined>;
31
+ };
32
+ } & P;
33
+ ```
34
+
35
+ ## Parameters
36
+
37
+ <table><thead><tr><th>
38
+
39
+ Parameter
40
+
41
+
42
+ </th><th>
43
+
44
+ Type
45
+
46
+
47
+ </th><th>
48
+
49
+ Description
50
+
51
+
52
+ </th></tr></thead>
53
+ <tbody><tr><td>
54
+
55
+ ParentClass
56
+
57
+
58
+ </td><td>
59
+
60
+ P
61
+
62
+
63
+ </td><td>
64
+
65
+
66
+ </td></tr>
67
+ </tbody></table>
68
+ **Returns:**
69
+
70
+ { new (...args: any): { \[x: string\]: any; readonly isDestroyed: boolean; \_isDestroyed: boolean; \_destroyers: [FunDestroyer](./destroyable.fundestroyer.md)<!-- -->\[\]; disposeFun&lt;T extends [FunDestroyer](./destroyable.fundestroyer.md)<!-- -->&gt;(fun: T): T; cancelDisposeFun&lt;T extends [FunDestroyer](./destroyable.fundestroyer.md)<!-- -->&gt;(fun: T): T; disposeObj&lt;T extends /\*elided\*/ any&gt;(obj: T, sync?: boolean): T; cancelDisposeObj&lt;T extends /\*elided\*/ any&gt;(obj: T): T; dispose&lt;T extends [FunDestroyer](./destroyable.fundestroyer.md)<!-- -->&gt;(fun: T): T; dispose&lt;T extends /\*elided\*/ any&gt;(obj: T, asyncDestroy?: boolean): T; dispose&lt;T extends /\*elided\*/ any \| [FunDestroyer](./destroyable.fundestroyer.md)<!-- -->&gt;(objOrFun: T, asyncDestroy?: boolean): T; cancelDispose&lt;T extends [FunDestroyer](./destroyable.fundestroyer.md)<!-- -->&gt;(fun: T): T; cancelDispose&lt;T extends /\*elided\*/ any&gt;(obj: T): T; cancelDispose&lt;T extends /\*elided\*/ any \| [FunDestroyer](./destroyable.fundestroyer.md)<!-- -->&gt;(objOrFun: T): T; destroyThis(): void; destroy(): true \| undefined; destroyAsync(): Promise&lt;true \| undefined&gt;; }; } &amp; P
71
+
72
+
73
+ ## Remarks
74
+
75
+ 用于根据传入的父类 动态生成可可销毁的子类
76
+
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@gby/destroyable](./destroyable.md) &gt; [Destroyable](./destroyable.destroyable.md) &gt; [\_destroyers](./destroyable.destroyable._destroyers.md)
4
+
5
+ ## Destroyable.\_destroyers property
6
+
7
+ 销毁者
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ _destroyers: FunDestroyer[];
13
+ ```
@@ -0,0 +1,11 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@gby/destroyable](./destroyable.md) &gt; [Destroyable](./destroyable.destroyable.md) &gt; [\_isDestroyed](./destroyable.destroyable._isdestroyed.md)
4
+
5
+ ## Destroyable.\_isDestroyed property
6
+
7
+ **Signature:**
8
+
9
+ ```typescript
10
+ _isDestroyed: boolean;
11
+ ```
@@ -0,0 +1,49 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@gby/destroyable](./destroyable.md) &gt; [Destroyable](./destroyable.destroyable.md) &gt; [cancelDispose](./destroyable.destroyable.canceldispose.md)
4
+
5
+ ## Destroyable.cancelDispose() method
6
+
7
+ **Signature:**
8
+
9
+ ```typescript
10
+ cancelDispose<T extends FunDestroyer>(fun: T): T;
11
+ ```
12
+
13
+ ## Parameters
14
+
15
+ <table><thead><tr><th>
16
+
17
+ Parameter
18
+
19
+
20
+ </th><th>
21
+
22
+ Type
23
+
24
+
25
+ </th><th>
26
+
27
+ Description
28
+
29
+
30
+ </th></tr></thead>
31
+ <tbody><tr><td>
32
+
33
+ fun
34
+
35
+
36
+ </td><td>
37
+
38
+ T
39
+
40
+
41
+ </td><td>
42
+
43
+
44
+ </td></tr>
45
+ </tbody></table>
46
+ **Returns:**
47
+
48
+ T
49
+
@@ -0,0 +1,49 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@gby/destroyable](./destroyable.md) &gt; [Destroyable](./destroyable.destroyable.md) &gt; [cancelDispose](./destroyable.destroyable.canceldispose_1.md)
4
+
5
+ ## Destroyable.cancelDispose() method
6
+
7
+ **Signature:**
8
+
9
+ ```typescript
10
+ cancelDispose<T extends Destroyable>(obj: T): T;
11
+ ```
12
+
13
+ ## Parameters
14
+
15
+ <table><thead><tr><th>
16
+
17
+ Parameter
18
+
19
+
20
+ </th><th>
21
+
22
+ Type
23
+
24
+
25
+ </th><th>
26
+
27
+ Description
28
+
29
+
30
+ </th></tr></thead>
31
+ <tbody><tr><td>
32
+
33
+ obj
34
+
35
+
36
+ </td><td>
37
+
38
+ T
39
+
40
+
41
+ </td><td>
42
+
43
+
44
+ </td></tr>
45
+ </tbody></table>
46
+ **Returns:**
47
+
48
+ T
49
+
@@ -0,0 +1,49 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@gby/destroyable](./destroyable.md) &gt; [Destroyable](./destroyable.destroyable.md) &gt; [cancelDispose](./destroyable.destroyable.canceldispose_2.md)
4
+
5
+ ## Destroyable.cancelDispose() method
6
+
7
+ **Signature:**
8
+
9
+ ```typescript
10
+ cancelDispose<T extends Destroyable | FunDestroyer>(objOrFun: T): T;
11
+ ```
12
+
13
+ ## Parameters
14
+
15
+ <table><thead><tr><th>
16
+
17
+ Parameter
18
+
19
+
20
+ </th><th>
21
+
22
+ Type
23
+
24
+
25
+ </th><th>
26
+
27
+ Description
28
+
29
+
30
+ </th></tr></thead>
31
+ <tbody><tr><td>
32
+
33
+ objOrFun
34
+
35
+
36
+ </td><td>
37
+
38
+ T
39
+
40
+
41
+ </td><td>
42
+
43
+
44
+ </td></tr>
45
+ </tbody></table>
46
+ **Returns:**
47
+
48
+ T
49
+
@@ -0,0 +1,52 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@gby/destroyable](./destroyable.md) &gt; [Destroyable](./destroyable.destroyable.md) &gt; [cancelDisposeFun](./destroyable.destroyable.canceldisposefun.md)
4
+
5
+ ## Destroyable.cancelDisposeFun() method
6
+
7
+ 取消销毁者函数
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ cancelDisposeFun<T extends FunDestroyer>(fun: T): T;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ <table><thead><tr><th>
18
+
19
+ Parameter
20
+
21
+
22
+ </th><th>
23
+
24
+ Type
25
+
26
+
27
+ </th><th>
28
+
29
+ Description
30
+
31
+
32
+ </th></tr></thead>
33
+ <tbody><tr><td>
34
+
35
+ fun
36
+
37
+
38
+ </td><td>
39
+
40
+ T
41
+
42
+
43
+ </td><td>
44
+
45
+
46
+ </td></tr>
47
+ </tbody></table>
48
+ **Returns:**
49
+
50
+ T
51
+
52
+
@@ -0,0 +1,52 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@gby/destroyable](./destroyable.md) &gt; [Destroyable](./destroyable.destroyable.md) &gt; [cancelDisposeObj](./destroyable.destroyable.canceldisposeobj.md)
4
+
5
+ ## Destroyable.cancelDisposeObj() method
6
+
7
+ 取消销毁者函数
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ cancelDisposeObj<T extends Destroyable>(obj: T): T;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ <table><thead><tr><th>
18
+
19
+ Parameter
20
+
21
+
22
+ </th><th>
23
+
24
+ Type
25
+
26
+
27
+ </th><th>
28
+
29
+ Description
30
+
31
+
32
+ </th></tr></thead>
33
+ <tbody><tr><td>
34
+
35
+ obj
36
+
37
+
38
+ </td><td>
39
+
40
+ T
41
+
42
+
43
+ </td><td>
44
+
45
+
46
+ </td></tr>
47
+ </tbody></table>
48
+ **Returns:**
49
+
50
+ T
51
+
52
+
@@ -0,0 +1,17 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@gby/destroyable](./destroyable.md) &gt; [Destroyable](./destroyable.destroyable.md) &gt; [destroy](./destroyable.destroyable.destroy.md)
4
+
5
+ ## Destroyable.destroy() method
6
+
7
+ 销毁
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ destroy(): true | undefined;
13
+ ```
14
+ **Returns:**
15
+
16
+ true \| undefined
17
+
@@ -0,0 +1,21 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@gby/destroyable](./destroyable.md) &gt; [Destroyable](./destroyable.destroyable.md) &gt; [destroyAsync](./destroyable.destroyable.destroyasync.md)
4
+
5
+ ## Destroyable.destroyAsync() method
6
+
7
+ 异步销毁
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ destroyAsync(): Promise<true | undefined>;
13
+ ```
14
+ **Returns:**
15
+
16
+ Promise&lt;true \| undefined&gt;
17
+
18
+ ## Remarks
19
+
20
+ 会依次执行销毁,并且只有上一个销毁完成之后才会执行下一个销毁
21
+
@@ -0,0 +1,21 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@gby/destroyable](./destroyable.md) &gt; [Destroyable](./destroyable.destroyable.md) &gt; [destroyThis](./destroyable.destroyable.destroythis.md)
4
+
5
+ ## Destroyable.destroyThis() method
6
+
7
+ 自己的销毁方法
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ destroyThis(): void;
13
+ ```
14
+ **Returns:**
15
+
16
+ void
17
+
18
+ ## Remarks
19
+
20
+ 子类根据需要进行重载
21
+