8000 docs: add signals code example recipe book by devchas · Pull Request #62164 · angular/angular · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

docs: add signals code example recipe book #62164

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

devchas
Copy link
Contributor
@devchas devchas commented Jun 20, 2025

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@pullapprove pullapprove bot requested a review from kirjs June 20, 2025 15:29
@angular-robot angular-robot bot added the area: docs Related to the documentation label Jun 20, 2025
@ngbot ngbot bot added this to the Backlog milestone Jun 20, 2025
@MarkTechson MarkTechson self-requested a review June 20, 2025 16:00
@MarkTechson MarkTechson added action: review The PR is still awaiting reviews from at least one requested reviewer adev: preview labels Jun 20, 2025
<div class="result-box">
<div class="display-section">
<h3>Current User:</h3>
<pre>{{ '{' }}
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: use JsonPipe instead

Copy link
github-actions bot commented Jun 20, 2025

Deployed adev-preview for 790c47a to: https://ng-dev-previews-fw--pr-angular-angular-62164-adev-prev-a8hbslfy.web.app

Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt.

Copy link
Contributor
@MarkTechson MarkTechson left a comment

Choose a reason for hiding this comment

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

Can this be updated to use semantic HTML elements? Currently, div elements are used where there are better, more screen-reader friendly elements available such as section


### The Source of Truth: `signal()`

A writable signal, created with the `signal()` function, is the foundation of all reactive state. It's a container for a value that notifies consumers when it changes. You create it with an initial value and read it by calling it as a function, like `mySignal()`. State is changed using the `.set()` or `.update()` methods.
Copy link
Member

Choose a reason for hiding this comment

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

I worry a little that the framing text around the examples is doing too much work that duplicates the explanatory/introductory content we would have in the other topics/tutorials. IMO we should have one canonical journey where we explain the concepts in a particular guide, and reinforce that with examples

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've replaced the description text with links to relevant guides, unless there was no relevant guide, in which case I left the text as a stopgap. Thanks for the discussion here - I think this solution works well.

@bencodezen bencodezen requested a review from MarkTechson June 20, 2025 20:42
Copy link
Contributor
@bencodezen bencodezen left a comment

Choose a reason for hiding this comment

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

Hey @devchas! I like the way the code examples help to illustrate different concepts of signals.

As far as the explainers go though, I think it currently is at odds with the rest of the guide. Would it be possible to refactor this PR as enhancements to the guide as inline examples rather than a separate page?

@@ -0,0 +1,38 @@
<div class="container">
<h2>Demo: Immutability</h2>
<p>Always produce a new value when updating a signal that holds an object or array. Direct mutation, like using <code>.push()</code>, will not be detected by Angular's change detection. </p>
Copy link
Contributor

Choose a reason for hiding this comment

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

@MarkTechson Hi Mark, is the importance of immutability currently part of the AI rules files?
My personal experience is that proposed code snippets from AI often fall short on this.

Copy link
Contributor
@bencodezen bencodezen left a comment

Choose a reason for hiding this comment

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

Thanks for prototyping this initial concept @devchas! Let's put a pause on this for now and chat more with Jeremy to figure out the best way to enhance code examples on the docs site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: review The PR is still awaiting reviews from at least one requested reviewer adev: preview area: docs Related to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0