From a8eea1a73b2fe43f4784a6f5961be52ab4393bfa Mon Sep 17 00:00:00 2001 From: roymondchen Date: Thu, 31 Aug 2023 15:47:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(core):=20node=E9=94=80=E6=AF=81=E5=90=8E?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E6=B8=B2=E6=9F=93=E5=86=8D=E9=94=80=E6=AF=81?= =?UTF-8?q?=E4=B8=8D=E4=BC=9A=E8=A7=A6=E5=8F=91destroy=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/Node.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/core/src/Node.ts b/packages/core/src/Node.ts index 54396742..da2ec9b4 100644 --- a/packages/core/src/Node.ts +++ b/packages/core/src/Node.ts @@ -54,15 +54,6 @@ class Node extends EventEmitter { this.data = options.config; this.events = events || []; this.listenLifeSafe(); - - this.once('destroy', () => { - this.instance = null; - if (typeof this.data.destroy === 'function') { - this.data.destroy(this); - } - - this.listenLifeSafe(); - }); } public setData(data: MComponent | MContainer | MPage) { @@ -76,6 +67,15 @@ class Node extends EventEmitter { private listenLifeSafe() { this.once('created', async (instance: any) => { + this.once('destroy', () => { + this.instance = null; + if (typeof this.data.destroy === 'function') { + this.data.destroy(this); + } + + this.listenLifeSafe(); + }); + this.instance = instance; await this.runCodeBlock('created'); });