Skip to content

Commit 007452b

Browse files
committed
HOTIFX: wrong logic for Store decorator
1 parent d58a1e7 commit 007452b

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"configurations": [
3+
{
4+
"type": "chrome",
5+
"request": "launch",
6+
"name": "Launch Chrome against localhost",
7+
"url": "http://localhost:3333",
8+
"sourceMaps": true,
9+
"webRoot": "${workspaceFolder}/packages/ui-stencil",
10+
"sourceMapPathOverrides": {
11+
"*": "${webRoot}/*"
12+
}
13+
}
14+
]
15+
}

packages/ui-stencil/src/StoreDecorator.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export function Store<S extends StoresMapKeys>(storeName: S): PropertyDecorator
1717
if (!classConstructor[STORE_PROPS]) {
1818
classConstructor[STORE_PROPS] = []
1919
}
20-
// Add the property key to our metadata.
21-
classConstructor[STORE_PROPS].push(propKey)
20+
// Save both the property key and storeName in the metadata.
21+
classConstructor[STORE_PROPS].push({ propKey, storeName })
2222

2323
// Patch componentWillLoad only once for the class.
2424
if (!classConstructor[STORE_WILL_LOAD_PATCHED]) {
@@ -31,11 +31,11 @@ export function Store<S extends StoresMapKeys>(storeName: S): PropertyDecorator
3131
// Access the host element
3232
const hostEl = getElement(this)
3333

34-
const storeProps: (string | symbol)[] = this.constructor[STORE_PROPS]
34+
const storeProps = this.constructor[STORE_PROPS]
3535
if (storeProps) {
36-
for (const storeProp of storeProps) {
36+
for (const { propKey, storeName } of storeProps) {
3737
const store = getStore(storeName, hostEl)
38-
this[storeProp] = store
38+
this[propKey] = store
3939
}
4040
}
4141

0 commit comments

Comments
 (0)