-
Notifications
You must be signed in to change notification settings - Fork 26.3k
feat(core): introduce debugName optional arg to framework signal functions #57073
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
feat(core): introduce debugName optional arg to framework signal functions #57073
Conversation
6d94bb9
to
ef5240b
Compare
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.
LGTM
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.
Thanks @AleksanderBodurri, this look great! A lot more places to update than I expected. 😅
I just have one question about ngDevMode
usage and a few minor nits, but nothing too significant here.
@@ -56,7 +61,7 @@ export interface ModelSignal<T> extends WritableSignal<T>, InputSignal<T>, Outpu | |||
* Can be set to {@link REQUIRED_UNSET_VALUE} for required model signals. | |||
* @param options Additional options for the model. | |||
*/ | |||
export function createModelSignal<T>(initialValue: T): ModelSignal<T> { | |||
export function createModelSignal<T>(initialValue: T, opts?: ModelOptions): ModelSignal<T> { |
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.
ModelOptions
's alias isn't used in the function. Should we narrow down the type here ?
70c8e84
to
8ce5039
Compare
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.
@alxhub, can you take a look? Any concerns on your end?
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.
Generally this LGTM. For g3sync reasons you'll need to separate the changes to @angular/core/primitives
code into a separate PR, plus there are a few topics to discuss on
@@ -34,5 +39,8 @@ export function computed<T>(computation: () => T, options?: CreateComputedOption | |||
if (ngDevMode) { | |||
getter.toString = () => `[Computed: ${getter()}]`; | |||
} | |||
|
|||
getter[SIGNAL].debugName = options?.debugName; |
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.
Should we not assign this only inngDevMode
above? Also, we should conditionally assign only if options?.debugName
is defined (otherwise we add an extra property to all nodes of this type, which has a high memory cost).
e96e1f7
to
3d7835b
Compare
53a0a0a
to
a15259f
Compare
…tions Angular DevTools is working on developing signal debugging support. This commit is a step in the direction of making available debug information to the framework that will allow Angular DevTools to provide users with more accurate information regarding the usage of signals in their applications. Follow up PRs that will use this arg will: - Develop a typescript transform that will detect usages of signal functions and attempt to add a debugName without the user needing to specify one directly - Develop debug APIs for discovering signal graphs within Angular applications (using debugName as a way to label nodes on the graph)
a15259f
to
48b42ee
Compare
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.
Reviewed-for: public-api
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.
reviewed-for: public-api
Caretaker: this is "green" in g3. |
This PR was merged into the repository by commit ec386e7. The changes were merged into the following branches: main |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Blocked by #57710
Angular DevTools is working on developing signal debugging support. This commit is a step in the direction of making available debug information to the framework that will allow Angular DevTools to provide users with more accurate information regarding the usage of signals in their applications.
Follow up PRs that will use this arg will: