refactor: 及时释放没用变量
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { nextTick, reactive, ref } from 'vue-demi';
|
||||
import { nextTick, onBeforeUnmount, reactive, ref } from 'vue-demi';
|
||||
|
||||
import Core from '@tmagic/core';
|
||||
import type { ChangeEvent } from '@tmagic/data-source';
|
||||
@@ -8,7 +8,7 @@ import { isPage, replaceChildNode } from '@tmagic/utils';
|
||||
export const useDsl = (app: Core | undefined) => {
|
||||
const pageConfig = ref(app?.page?.data || {});
|
||||
|
||||
app?.dataSourceManager?.on('update-data', (nodes: MNode[], sourceId: string, changeEvent: ChangeEvent) => {
|
||||
const updateDataHandler = (nodes: MNode[], sourceId: string, changeEvent: ChangeEvent) => {
|
||||
nodes.forEach((node) => {
|
||||
if (isPage(node)) {
|
||||
pageConfig.value = node;
|
||||
@@ -22,6 +22,12 @@ export const useDsl = (app: Core | undefined) => {
|
||||
nextTick(() => {
|
||||
app.emit('replaced-node', { nodes, sourceId, ...changeEvent });
|
||||
});
|
||||
};
|
||||
|
||||
app?.dataSourceManager?.on('update-data', updateDataHandler);
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
app?.dataSourceManager?.off('update-data', updateDataHandler);
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user