-
Notifications
You must be signed in to change notification settings - Fork 0
Improve useProperties typing for key→type maps #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,12 +39,16 @@ createEffect(() => { | |
|
|
||
| A convenience helper to create multiple property signals at once. | ||
|
|
||
| * **Signature:** `useProperties(map: Record<string, any>): Record<string, () => any>` | ||
| * **Signature:** `useProperties<T>(map: { [K in keyof T]: string }): { [K in keyof T]: () => T[K] | undefined }` | ||
| * **Returns:** An object where keys match the input map, and values are signal readers. | ||
|
Comment on lines
+42
to
43
|
||
|
|
||
| ```typescript | ||
| const { x, y } = useProperties({ x: 0, y: 0 }); | ||
| // x() and y() are now signals | ||
| const { foo, bar } = useProperties<{ foo: number; bar: string }>({ | ||
| foo: 'prop.name.foo', | ||
| bar: 'prop.bar', | ||
| }); | ||
| // foo(): number | undefined | ||
| // bar(): string | undefined | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,16 +118,15 @@ class GameEntity { | |
| }); | ||
|
|
||
| // Sync position to Shadow World | ||
| this.viewComponent.setProperties({ | ||
| x: this.x, | ||
| y: this.y | ||
| }); | ||
| this.viewComponent.setProperty('x', this.x); | ||
| this.viewComponent.setProperty('y', this.y); | ||
|
Comment on lines
+121
to
+122
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please revert changes - the use of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverted the second setProperties example in the view-components doc. Commit: ad9339d. |
||
| } | ||
|
|
||
| update() { | ||
| // Send updates every frame (or optimally, only on change) | ||
| if (this.moved) { | ||
| this.viewComponent.setProperties({ x: this.x, y: this.y }); | ||
| this.viewComponent.setProperty('x', this.x); | ||
| this.viewComponent.setProperty('y', this.y); | ||
|
Comment on lines
+128
to
+129
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please revert changes - the use of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverted the view-components doc example to use setProperties again as requested. Commit: ad9339d. |
||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please revert changes - do not use
setProprties()with a single property. thats forsetPropertyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted the guide example back to useProperty instead of setProperties for a single field. Commit: ad9339d.