重构了loadingMore的代码
This commit is contained in:
parent
a702a08e8e
commit
b880bc659b
|
|
@ -50,7 +50,6 @@ declare abstract class Node<ED extends EntityDict & BaseEntityDict> extends Feat
|
|||
private count;
|
||||
protected executing: boolean;
|
||||
protected dirty?: boolean;
|
||||
protected loadingMore: boolean;
|
||||
private extraData;
|
||||
private refreshing;
|
||||
private refreshCallbacks;
|
||||
|
|
@ -72,7 +71,6 @@ declare abstract class Node<ED extends EntityDict & BaseEntityDict> extends Feat
|
|||
setExecuting(executing: boolean): void;
|
||||
protected startRefreshing(num: number): number | Promise<void>;
|
||||
protected endRefreshing(num: number, error?: any): void;
|
||||
isLoadingMore(): boolean;
|
||||
saveExtraData(key: string, data: any): void;
|
||||
loadExtraData(key: string): any;
|
||||
isStale(): boolean;
|
||||
|
|
@ -102,6 +100,7 @@ declare class ListNode<ED extends EntityDict & BaseEntityDict, T extends keyof E
|
|||
private getTotal?;
|
||||
private pagination;
|
||||
private sr;
|
||||
private loadingMore;
|
||||
private syncHandler;
|
||||
setFiltersAndSortedApplied(): void;
|
||||
private startLoading;
|
||||
|
|
@ -115,6 +114,7 @@ declare class ListNode<ED extends EntityDict & BaseEntityDict, T extends keyof E
|
|||
constructor(entity: T, schema: StorageSchema<ED>, cache: Cache<ED>, fullPath: string, projection?: ED[T]['Projection'] | (() => Promise<ED[T]['Projection']>), parent?: SingleNode<ED, keyof ED> | VirtualNode<ED>, path?: string, filters?: NamedFilterItem<ED, T>[], sorters?: NamedSorterItem<ED, T>[], getTotal?: number, pagination?: Pick<Pagination, 'currentPage' | 'pageSize' | 'randomRange'>, stale?: boolean);
|
||||
getPagination(): Pagination;
|
||||
setPagination(pagination: Pick<Pagination, 'currentPage' | 'pageSize' | 'randomRange'>, dontRefresh?: true): void;
|
||||
isLoadingMore(): boolean;
|
||||
addChild(path: string, node: SingleNode<ED, T>): void;
|
||||
removeChild(path: string): void;
|
||||
getChild(path: string): SingleNode<ED, T>;
|
||||
|
|
|
|||
|
|
@ -207,7 +207,6 @@ class Node extends Feature {
|
|||
count = 0;
|
||||
executing = false;
|
||||
dirty;
|
||||
loadingMore = false;
|
||||
extraData = {};
|
||||
refreshing = 0;
|
||||
refreshCallbacks = [];
|
||||
|
|
@ -282,9 +281,6 @@ class Node extends Feature {
|
|||
});
|
||||
}
|
||||
}
|
||||
isLoadingMore() {
|
||||
return this.loadingMore;
|
||||
}
|
||||
saveExtraData(key, data) {
|
||||
this.extraData[key] = data;
|
||||
}
|
||||
|
|
@ -312,7 +308,6 @@ class EntityNode extends Node {
|
|||
this.projection = projection;
|
||||
this.parent = parent;
|
||||
this.dirty = undefined;
|
||||
this.loadingMore = false;
|
||||
this.executing = false;
|
||||
this.ulManager = new UpdateLogManager(this.schema, this.entity);
|
||||
}
|
||||
|
|
@ -362,6 +357,7 @@ class ListNode extends EntityNode {
|
|||
getTotal;
|
||||
pagination = { ...DEFAULT_PAGINATION };
|
||||
sr = {};
|
||||
loadingMore = false;
|
||||
syncHandler;
|
||||
setFiltersAndSortedApplied() {
|
||||
this.filters.forEach(ele => ele.applied = true);
|
||||
|
|
@ -643,6 +639,9 @@ class ListNode extends EntityNode {
|
|||
this.refresh(0, false);
|
||||
}
|
||||
}
|
||||
isLoadingMore() {
|
||||
return this.loadingMore;
|
||||
}
|
||||
addChild(path, node) {
|
||||
assert(!this.children[path]);
|
||||
// assert(path.length > 10, 'List的path改成了id');
|
||||
|
|
@ -2174,7 +2173,7 @@ export class RunningTree extends Feature {
|
|||
}
|
||||
isLoadingMore(path) {
|
||||
const node = this.findNode(path);
|
||||
assert(!node || (node instanceof SingleNode || node instanceof ListNode));
|
||||
assert(!node || (node instanceof ListNode));
|
||||
return node?.isLoadingMore();
|
||||
}
|
||||
isExecuting(path) {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ declare abstract class Node<ED extends EntityDict & BaseEntityDict> extends Feat
|
|||
private count;
|
||||
protected executing: boolean;
|
||||
protected dirty?: boolean;
|
||||
protected loadingMore: boolean;
|
||||
private extraData;
|
||||
private refreshing;
|
||||
private refreshCallbacks;
|
||||
|
|
@ -72,7 +71,6 @@ declare abstract class Node<ED extends EntityDict & BaseEntityDict> extends Feat
|
|||
setExecuting(executing: boolean): void;
|
||||
protected startRefreshing(num: number): number | Promise<void>;
|
||||
protected endRefreshing(num: number, error?: any): void;
|
||||
isLoadingMore(): boolean;
|
||||
saveExtraData(key: string, data: any): void;
|
||||
loadExtraData(key: string): any;
|
||||
isStale(): boolean;
|
||||
|
|
@ -102,6 +100,7 @@ declare class ListNode<ED extends EntityDict & BaseEntityDict, T extends keyof E
|
|||
private getTotal?;
|
||||
private pagination;
|
||||
private sr;
|
||||
private loadingMore;
|
||||
private syncHandler;
|
||||
setFiltersAndSortedApplied(): void;
|
||||
private startLoading;
|
||||
|
|
@ -115,6 +114,7 @@ declare class ListNode<ED extends EntityDict & BaseEntityDict, T extends keyof E
|
|||
constructor(entity: T, schema: StorageSchema<ED>, cache: Cache<ED>, fullPath: string, projection?: ED[T]['Projection'] | (() => Promise<ED[T]['Projection']>), parent?: SingleNode<ED, keyof ED> | VirtualNode<ED>, path?: string, filters?: NamedFilterItem<ED, T>[], sorters?: NamedSorterItem<ED, T>[], getTotal?: number, pagination?: Pick<Pagination, 'currentPage' | 'pageSize' | 'randomRange'>, stale?: boolean);
|
||||
getPagination(): Pagination;
|
||||
setPagination(pagination: Pick<Pagination, 'currentPage' | 'pageSize' | 'randomRange'>, dontRefresh?: true): void;
|
||||
isLoadingMore(): boolean;
|
||||
addChild(path: string, node: SingleNode<ED, T>): void;
|
||||
removeChild(path: string): void;
|
||||
getChild(path: string): SingleNode<ED, T>;
|
||||
|
|
|
|||
|
|
@ -210,7 +210,6 @@ class Node extends Feature_1.Feature {
|
|||
count = 0;
|
||||
executing = false;
|
||||
dirty;
|
||||
loadingMore = false;
|
||||
extraData = {};
|
||||
refreshing = 0;
|
||||
refreshCallbacks = [];
|
||||
|
|
@ -285,9 +284,6 @@ class Node extends Feature_1.Feature {
|
|||
});
|
||||
}
|
||||
}
|
||||
isLoadingMore() {
|
||||
return this.loadingMore;
|
||||
}
|
||||
saveExtraData(key, data) {
|
||||
this.extraData[key] = data;
|
||||
}
|
||||
|
|
@ -315,7 +311,6 @@ class EntityNode extends Node {
|
|||
this.projection = projection;
|
||||
this.parent = parent;
|
||||
this.dirty = undefined;
|
||||
this.loadingMore = false;
|
||||
this.executing = false;
|
||||
this.ulManager = new UpdateLogManager(this.schema, this.entity);
|
||||
}
|
||||
|
|
@ -365,6 +360,7 @@ class ListNode extends EntityNode {
|
|||
getTotal;
|
||||
pagination = { ...DEFAULT_PAGINATION };
|
||||
sr = {};
|
||||
loadingMore = false;
|
||||
syncHandler;
|
||||
setFiltersAndSortedApplied() {
|
||||
this.filters.forEach(ele => ele.applied = true);
|
||||
|
|
@ -646,6 +642,9 @@ class ListNode extends EntityNode {
|
|||
this.refresh(0, false);
|
||||
}
|
||||
}
|
||||
isLoadingMore() {
|
||||
return this.loadingMore;
|
||||
}
|
||||
addChild(path, node) {
|
||||
(0, assert_1.assert)(!this.children[path]);
|
||||
// assert(path.length > 10, 'List的path改成了id');
|
||||
|
|
@ -2177,7 +2176,7 @@ class RunningTree extends Feature_1.Feature {
|
|||
}
|
||||
isLoadingMore(path) {
|
||||
const node = this.findNode(path);
|
||||
(0, assert_1.assert)(!node || (node instanceof SingleNode || node instanceof ListNode));
|
||||
(0, assert_1.assert)(!node || (node instanceof ListNode));
|
||||
return node?.isLoadingMore();
|
||||
}
|
||||
isExecuting(path) {
|
||||
|
|
|
|||
|
|
@ -259,7 +259,6 @@ abstract class Node<ED extends EntityDict & BaseEntityDict> extends Feature {
|
|||
private count: number = 0;
|
||||
protected executing: boolean = false;
|
||||
protected dirty?: boolean;
|
||||
protected loadingMore: boolean = false;
|
||||
private extraData: Record<string, any> = {};
|
||||
private refreshing: number = 0;
|
||||
private refreshCallbacks: Array<[() => void, (error?: any) => void]> = [];
|
||||
|
|
@ -361,10 +360,6 @@ abstract class Node<ED extends EntityDict & BaseEntityDict> extends Feature {
|
|||
}
|
||||
}
|
||||
|
||||
isLoadingMore() {
|
||||
return this.loadingMore;
|
||||
}
|
||||
|
||||
saveExtraData(key: string, data: any) {
|
||||
this.extraData[key] = data;
|
||||
}
|
||||
|
|
@ -402,7 +397,6 @@ abstract class EntityNode<
|
|||
this.projection = projection;
|
||||
this.parent = parent;
|
||||
this.dirty = undefined;
|
||||
this.loadingMore = false;
|
||||
this.executing = false;
|
||||
this.ulManager = new UpdateLogManager(this.schema, this.entity);
|
||||
}
|
||||
|
|
@ -467,6 +461,7 @@ class ListNode<
|
|||
private getTotal?: number;
|
||||
private pagination: Pagination = { ...DEFAULT_PAGINATION };
|
||||
private sr: Record<string, any> = {};
|
||||
private loadingMore: boolean = false;
|
||||
|
||||
private syncHandler: (records: OpRecord<ED>[]) => void;
|
||||
|
||||
|
|
@ -799,6 +794,11 @@ class ListNode<
|
|||
}
|
||||
}
|
||||
|
||||
isLoadingMore() {
|
||||
return this.loadingMore;
|
||||
}
|
||||
|
||||
|
||||
addChild(path: string, node: SingleNode<ED, T>) {
|
||||
assert(!this.children[path]);
|
||||
// assert(path.length > 10, 'List的path改成了id');
|
||||
|
|
@ -2643,9 +2643,7 @@ export class RunningTree<ED extends EntityDict & BaseEntityDict> extends Feature
|
|||
|
||||
isLoadingMore(path: string) {
|
||||
const node = this.findNode(path);
|
||||
assert(
|
||||
!node || (node instanceof SingleNode || node instanceof ListNode)
|
||||
);
|
||||
assert(!node || (node instanceof ListNode));
|
||||
return node?.isLoadingMore();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue