天天看點

SAP Spartacus B2B子產品 State的設計原理

SAP Spartacus B2B子產品 State的設計原理
SAP Spartacus B2B子產品 State的設計原理

export interface Management<Type> extends StateUtils.EntityListState<Type> {}

展開:

Management<UserGroup>

相當于

StateUtils.EntityListState<UserGroup>:

export interface EntityListState<Type> {

 list: EntityLoaderState<ListModel>;

 entities: EntityLoaderState<Type>;

}

相當于:

EntityListState<UserGroup>{

list: EntityLoaderState<ListModel>;

entity: EntityLoaderState<UserGroup>;

export type EntityLoaderState = EntityState<LoaderState>;

list: EntityState<LoaderState<ListModel>;

entity: EntityState<LoaderState<UserGroup>;

list: EntityState<loading, error, success, value: ListModel>;

entity: EntityState<loading, error, success, value: UserGroup>;

list: entities: {

   [id: string]: loading, error, success, value: ListModel

 }

entity: entities: {

   [id: string]: loading, error, success, value: UserGroup

 };

例子:

SAP Spartacus B2B子產品 State的設計原理

entities stores real user group objects, which are key mapped to status flags and values

list stores a list of user groups IDs for specified pages, with keys based on query parameters, such as pagination and sorts

customers stores IDs for a subsection, with keys based on the ID of the user group and query parameters

permisions stores IDs for a subsection, with keys based on the ID of the user group and query parameters

pageSize=2147483647 indicates that Spartacus fetches all possible items, up to the maximum safe Java integer