Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Conversation

AleksanderBodurri
Copy link
Member

@AleksanderBodurri AleksanderBodurri commented Jul 22, 2024

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:

  • Develop debug APIs for discovering signal graphs within Angular applications (using debugName as a way to label nodes on the graph) (refactor(core): implement experimental getSignalGraph debug API  #57074)
  • 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.

@pullapprove pullapprove bot requested review from alxhub and tbondwilkinson July 22, 2024 04:52
@pullapprove pullapprove bot added the requires: TGP This PR requires a passing TGP before merging is allowed label Jul 22, 2024
@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: core Issues related to the framework runtime labels Jul 22, 2024
@ngbot ngbot bot added this to the Backlog milestone Jul 22, 2024
@AleksanderBodurri AleksanderBodurri force-pushed the signal-function-debug-name branch from 6d94bb9 to ef5240b Compare July 22, 2024 04:55
@pullapprove pullapprove bot requested review from alxhub and tbondwilkinson July 22, 2024 06:44
@tbondwilkinson tbondwilkinson requested review from mturco and removed request for tbondwilkinson July 22, 2024 16:43
Copy link
Contributor

@mturco mturco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@dgp1130 dgp1130 left a 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> {
Copy link
Member

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 ?

@AleksanderBodurri AleksanderBodurri force-pushed the signal-function-debug-name branch 2 times, most recently from 70c8e84 to 8ce5039 Compare July 29, 2024 16:49
Copy link
Contributor

@dgp1130 dgp1130 left a 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?

Copy link
Member

@alxhub alxhub left a 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;
Copy link
Member

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).

@AleksanderBodurri AleksanderBodurri force-pushed the signal-function-debug-name branch 2 times, most recently from e96e1f7 to 3d7835b Compare September 12, 2024 17:11
@pullapprove pullapprove bot removed the requires: TGP This PR requires a passing TGP before merging is allowed label Sep 12, 2024
@AleksanderBodurri AleksanderBodurri force-pushed the signal-function-debug-name branch from 53a0a0a to a15259f Compare October 19, 2024 05:19
@angular-robot angular-robot bot added area: core Issues related to the framework runtime and removed area: core Issues related to the framework runtime labels Oct 19, 2024
…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)
@AleksanderBodurri AleksanderBodurri force-pushed the signal-function-debug-name branch from a15259f to 48b42ee Compare October 19, 2024 19:00
@angular-robot angular-robot bot added area: core Issues related to the framework runtime and removed area: core Issues related to the framework runtime labels Oct 19, 2024
@alxhub alxhub added the target: minor This PR is targeted for the next minor release label Oct 21, 2024
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a 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

@pullapprove pullapprove bot requested a review from thePunderWoman October 22, 2024 01:56
Copy link
Contributor

@thePunderWoman thePunderWoman left a 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

@pkozlowski-opensource pkozlowski-opensource removed their request for review October 22, 2024 14:24
@dgp1130 dgp1130 added the action: merge The PR is ready for merge by the caretaker label Oct 22, 2024
@ngbot
Copy link

ngbot bot commented Oct 22, 2024

I see that you just added the action: merge label, but the following checks are still failing:
    failure status "google-internal-tests" is failing
    pending status "mergeability" is pending
    pending 1 pending code review

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken main, please try rebasing to main and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@alxhub alxhub added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Oct 22, 2024
@alxhub
Copy link
Member

alxhub commented Oct 22, 2024

Caretaker: this is "green" in g3.

@AndrewKushnir
Copy link
Contributor

This PR was merged into the repository by commit ec386e7.

The changes were merged into the following branches: main

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime detected: feature PR contains a feature commit merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants