[IMP] store: connected component reuse base component name

Connected component should have a unique name. To achieve this the
connected component currently have an id based generated name (like
`ConnectedComponent1`).

To make it clearer and ease debugging this commit reuse the extended
component's name to include it in the generated name in the form of
`Connected<ComponentName>`.
This commit is contained in:
Pierre Paridans
2019-06-20 11:38:00 +02:00
committed by Géry Debongnie
parent 35c1de26b8
commit 5524c2e323
2 changed files with 18 additions and 3 deletions
+1 -3
View File
@@ -170,8 +170,6 @@ interface StoreOptions {
deep?: boolean;
}
let nextID = 1;
export function connect<E extends EnvWithStore, P, S>(
Comp: Constructor<Component<E, P, S>>,
mapStoreToProps,
@@ -292,7 +290,7 @@ export function connect<E extends EnvWithStore, P, S>(
// this is necessary for Owl to be able to properly deduce templates.
// Otherwise, all connected components would have the same name, and then
// each component after the first will necessarily have the same template.
let name = `ConnectedComponent${nextID++}`;
let name = `Connected${Comp.name}`;
Object.defineProperty(Result, "name", { value: name });
return Result;
}