From 204ca25952971c907c1ce95df673f9c7a0a7233b Mon Sep 17 00:00:00 2001 From: "Xc@centOs" Date: Wed, 18 Oct 2023 15:24:37 +0800 Subject: [PATCH] =?UTF-8?q?runningTree=E5=9C=A8refresh=E6=97=B6publish?= =?UTF-8?q?=E5=BA=94=E5=BD=93=E6=89=A9=E6=95=A3=E5=88=B0=E8=87=AA=E8=BA=AB?= =?UTF-8?q?=E6=89=80=E6=9C=89=E7=9A=84=E5=AD=90=E7=BB=93=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es/features/runningTree.d.ts | 3 +++ es/features/runningTree.js | 38 ++++++++++++++++++++++++-------- lib/features/runningTree.d.ts | 3 +++ lib/features/runningTree.js | 38 ++++++++++++++++++++++++-------- src/features/runningTree.ts | 41 +++++++++++++++++++++++++++-------- 5 files changed, 96 insertions(+), 27 deletions(-) diff --git a/es/features/runningTree.d.ts b/es/features/runningTree.d.ts index fdf10fa7..e2ccb470 100644 --- a/es/features/runningTree.d.ts +++ b/es/features/runningTree.d.ts @@ -129,6 +129,7 @@ declare class ListNode): ED[T]["CreateSingle"] | ED[T]["Update"] | ED[T]["Remove"] | undefined; getIntrinsticFilters(): ED[T]["Selection"]["filter"] | undefined; + publishRecursively(): void; } declare class SingleNode, FrontCxt extends SyncContext, AD extends CommonAspectDict> extends Node { private id?; @@ -175,6 +176,7 @@ declare class SingleNode(childNode: Node, ignoreNewParent?: boolean): ED[T2]['Selection']['filter'] | undefined; + publishRecursively(): void; } declare class VirtualNode, FrontCxt extends SyncContext, AD extends CommonAspectDict> extends Feature { private dirty; @@ -203,6 +205,7 @@ declare class VirtualNode; clean(): void; checkIfClean(): void; + publishRecursively(): void; } export type CreateNodeOptions = { path: string; diff --git a/es/features/runningTree.js b/es/features/runningTree.js index 85903d97..b1c75e18 100644 --- a/es/features/runningTree.js +++ b/es/features/runningTree.js @@ -718,7 +718,7 @@ class ListNode extends Node { if (append) { this.loadingMore = true; } - this.publish(); + this.publishRecursively(); await this.cache.refresh(entity, { data: projection, filter, @@ -750,20 +750,20 @@ class ListNode extends Node { this.aggr = aggr; } }); - this.publish(); + this.publishRecursively(); } catch (err) { this.setLoading(false); if (append) { this.loadingMore = false; } - this.publish(); + this.publishRecursively(); throw err; } } else { // 不刷新也publish一下,触发页面reRender,不然有可能导致页面不进入formData - this.publish(); + this.publishRecursively(); } } async loadMore() { @@ -814,6 +814,12 @@ class ListNode extends Node { const filters = this.constructFilters(undefined, true, true); return combineFilters(this.entity, this.schema, filters || []); } + publishRecursively() { + this.publish(); + for (const child in this.children) { + this.children[child].publishRecursively(); + } + } } class SingleNode extends Node { id; @@ -1170,7 +1176,7 @@ class SingleNode extends Node { const filter = this.getFilter(); if (projection && filter) { this.setLoading(true); - this.publish(); + this.publishRecursively(); try { const { data: [value] } = await this.cache.refresh(this.entity, { data: projection, @@ -1198,17 +1204,17 @@ class SingleNode extends Node { this.setLoading(false); //this.clean(); }); - this.publish(); + this.publishRecursively(); } catch (err) { this.setLoading(false); - this.publish(); + this.publishRecursively(); throw err; } } else { // 不刷新也publish一下,触发页面reRender,不然有可能导致页面不进入formData - this.publish(); + this.publishRecursively(); } } clean() { @@ -1355,6 +1361,12 @@ class SingleNode extends Node { } return; } + publishRecursively() { + this.publish(); + for (const child in this.children) { + this.children[child].publishRecursively(); + } + } } class VirtualNode extends Feature { dirty; @@ -1415,13 +1427,15 @@ class VirtualNode extends Feature { } async refresh() { this.loading = true; + this.publishRecursively(); try { await Promise.all(Object.keys(this.children).map(ele => this.children[ele].refresh())); this.loading = false; - this.publish(); + this.publishRecursively(); } catch (err) { this.loading = false; + this.publishRecursively(); throw err; } } @@ -1492,6 +1506,12 @@ class VirtualNode extends Feature { } this.dirty = false; } + publishRecursively() { + this.publish(); + for (const child in this.children) { + this.children[child].publishRecursively(); + } + } } function analyzePath(path) { const idx = path.lastIndexOf('.'); diff --git a/lib/features/runningTree.d.ts b/lib/features/runningTree.d.ts index fdf10fa7..e2ccb470 100644 --- a/lib/features/runningTree.d.ts +++ b/lib/features/runningTree.d.ts @@ -129,6 +129,7 @@ declare class ListNode): ED[T]["CreateSingle"] | ED[T]["Update"] | ED[T]["Remove"] | undefined; getIntrinsticFilters(): ED[T]["Selection"]["filter"] | undefined; + publishRecursively(): void; } declare class SingleNode, FrontCxt extends SyncContext, AD extends CommonAspectDict> extends Node { private id?; @@ -175,6 +176,7 @@ declare class SingleNode(childNode: Node, ignoreNewParent?: boolean): ED[T2]['Selection']['filter'] | undefined; + publishRecursively(): void; } declare class VirtualNode, FrontCxt extends SyncContext, AD extends CommonAspectDict> extends Feature { private dirty; @@ -203,6 +205,7 @@ declare class VirtualNode; clean(): void; checkIfClean(): void; + publishRecursively(): void; } export type CreateNodeOptions = { path: string; diff --git a/lib/features/runningTree.js b/lib/features/runningTree.js index 3e4edc0e..e88e7ea1 100644 --- a/lib/features/runningTree.js +++ b/lib/features/runningTree.js @@ -721,7 +721,7 @@ class ListNode extends Node { if (append) { this.loadingMore = true; } - this.publish(); + this.publishRecursively(); await this.cache.refresh(entity, { data: projection, filter, @@ -753,20 +753,20 @@ class ListNode extends Node { this.aggr = aggr; } }); - this.publish(); + this.publishRecursively(); } catch (err) { this.setLoading(false); if (append) { this.loadingMore = false; } - this.publish(); + this.publishRecursively(); throw err; } } else { // 不刷新也publish一下,触发页面reRender,不然有可能导致页面不进入formData - this.publish(); + this.publishRecursively(); } } async loadMore() { @@ -817,6 +817,12 @@ class ListNode extends Node { const filters = this.constructFilters(undefined, true, true); return (0, filter_1.combineFilters)(this.entity, this.schema, filters || []); } + publishRecursively() { + this.publish(); + for (const child in this.children) { + this.children[child].publishRecursively(); + } + } } class SingleNode extends Node { id; @@ -1173,7 +1179,7 @@ class SingleNode extends Node { const filter = this.getFilter(); if (projection && filter) { this.setLoading(true); - this.publish(); + this.publishRecursively(); try { const { data: [value] } = await this.cache.refresh(this.entity, { data: projection, @@ -1201,17 +1207,17 @@ class SingleNode extends Node { this.setLoading(false); //this.clean(); }); - this.publish(); + this.publishRecursively(); } catch (err) { this.setLoading(false); - this.publish(); + this.publishRecursively(); throw err; } } else { // 不刷新也publish一下,触发页面reRender,不然有可能导致页面不进入formData - this.publish(); + this.publishRecursively(); } } clean() { @@ -1358,6 +1364,12 @@ class SingleNode extends Node { } return; } + publishRecursively() { + this.publish(); + for (const child in this.children) { + this.children[child].publishRecursively(); + } + } } class VirtualNode extends Feature_1.Feature { dirty; @@ -1418,13 +1430,15 @@ class VirtualNode extends Feature_1.Feature { } async refresh() { this.loading = true; + this.publishRecursively(); try { await Promise.all(Object.keys(this.children).map(ele => this.children[ele].refresh())); this.loading = false; - this.publish(); + this.publishRecursively(); } catch (err) { this.loading = false; + this.publishRecursively(); throw err; } } @@ -1495,6 +1509,12 @@ class VirtualNode extends Feature_1.Feature { } this.dirty = false; } + publishRecursively() { + this.publish(); + for (const child in this.children) { + this.children[child].publishRecursively(); + } + } } function analyzePath(path) { const idx = path.lastIndexOf('.'); diff --git a/src/features/runningTree.ts b/src/features/runningTree.ts index ea195206..10b004c7 100644 --- a/src/features/runningTree.ts +++ b/src/features/runningTree.ts @@ -921,7 +921,7 @@ class ListNode< if (append) { this.loadingMore = true; } - this.publish(); + this.publishRecursively(); await this.cache.refresh( entity, { @@ -957,19 +957,19 @@ class ListNode< } } ); - this.publish(); + this.publishRecursively(); } catch (err) { this.setLoading(false); if (append) { this.loadingMore = false; } - this.publish(); + this.publishRecursively(); throw err; } } else { // 不刷新也publish一下,触发页面reRender,不然有可能导致页面不进入formData - this.publish(); + this.publishRecursively(); } } @@ -1026,6 +1026,13 @@ class ListNode< const filters = this.constructFilters(undefined, true, true); return combineFilters(this.entity, this.schema, filters || []); } + + publishRecursively() { + this.publish(); + for (const child in this.children) { + this.children[child].publishRecursively(); + } + } } class SingleNode = {