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

Skip to content

feat(core): export signalGetFn from signal primitives #60497

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

Closed
wants to merge 1 commit into from

Conversation

mturco
Copy link
Contributor

@mturco mturco commented Mar 20, 2025

This exports signalGetFn from the shared signal primitives which follows suit from signalSetFn and signalUpdateFn (both are already exported).

@pullapprove pullapprove bot added the requires: TGP This PR requires a passing TGP before merging is allowed label Mar 20, 2025
@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: core Issues related to the framework runtime labels Mar 20, 2025
@ngbot ngbot bot added this to the Backlog milestone Mar 20, 2025
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.

LGTM

reviewed-for: primitives, public-api

@pkozlowski-opensource
Copy link
Member

@mturco it looks like the signalGetFn is actually unused in the primitives / Angular code. Which would mean that exporting it would put new usages on a otherwise unused code path.

FYI, Angular is using https://github.com/angular/angular/blob/main/packages/core/primitives/signals/src/signal.ts#L57-L60 which seems to have the same logic as signalGetFn.

Would love to know more about the intention / other possibilities here.

@mturco
Copy link
Contributor Author

mturco commented Mar 24, 2025

@pkozlowski-opensource the use case here is related to go/wiz:devtools-reactive-nodes.

We're using the recently added postProducerCreatedFn to hook into signal creation. This hook (like postSignalSetFn) passes the reactive node itself and not the getter function. So when we go to provide devtools with the signals a component created, we need a way to also provide the current value.

We could pass () => node.value to devtools but that wouldn't create a subscription so the extension UI would not update on signal writes. I suppose that could be mitigated by having that function also manually call producerAccessed? Would that be preferred to introducing usage of signalGetFn?

@mturco mturco force-pushed the expose-signal-get-fn branch from 3f8b79b to a6c10df Compare March 25, 2025 15:06
@pullapprove pullapprove bot requested a review from kirjs March 25, 2025 15:06
@mturco
Copy link
Contributor Author

mturco commented Mar 25, 2025

@pkozlowski-opensource this has been updated as discussed to have createSignal call signalGetFn which should align Wiz/Angular on the latter being the singular way we create getters.

@pullapprove pullapprove bot requested a review from kirjs March 25, 2025 15:30
This updates `createSignal` to use `signalGetFn` to define the signal getter and exports `signalGetFn` from the shared signal primitives.
@mturco mturco force-pushed the expose-signal-get-fn branch from a6c10df to d21005e Compare March 25, 2025 15:32
Copy link
Member

@pkozlowski-opensource pkozlowski-opensource left a comment

Choose a reason for hiding this comment

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

LGTM

Reviewed-for: public-api
Reviewed-for: primitives

@thePunderWoman thePunderWoman added action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release labels Mar 31, 2025
@ngbot
Copy link

ngbot bot commented Mar 31, 2025

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 2 pending code reviews

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.

@thePunderWoman
Copy link
Contributor

TESTED=see above presubmit (TGP not necessary for new code)

@thePunderWoman thePunderWoman 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 Mar 31, 2025
@thePunderWoman
Copy link
Contributor

caretaker note: failure is unrelated. This is ready to merge.

@thePunderWoman
Copy link
Contributor

This PR was merged into the repository by commit a4bad8d.

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 May 1, 2025
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 requires: TGP This PR requires a passing TGP before merging is allowed target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants