platform icon indicating copy to clipboard operation
platform copied to clipboard

docs(signals): mention re-use of `withComputed/withMethods`

Open michael-small opened this issue 7 months ago • 3 comments

Issue: https://github.com/ngrx/platform/issues/4669

PR Checklist

Please check if your PR fulfills the following requirements:

  • [x] The commit message follows our guidelines: https://github.com/ngrx/platform/blob/main/CONTRIBUTING.md#commit
  • [ ] Tests for the changes have been added (for bug fixes / features)
  • [ ] Documentation has been added / updated (for bug fixes / features)

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
[x] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Issue: docs(@ngrx/signals): add a mention of restructuring withComputed or withMethods for re-use in those features

Closes #4669

What is the new behavior?

Documentation mentions how to re-use a computed or function across or within a withComputed or withMethods

Does this PR introduce a breaking change?

[ ] Yes
[x] No

michael-small avatar May 13 '25 23:05 michael-small

Deploy Preview for ngrx-io ready!

Built without sensitive environment variables

Name Link
Latest commit 48c6aeb115b2652ceb4927d32c1ff8492f9ca39f
Latest deploy log https://app.netlify.com/projects/ngrx-io/deploys/6893d38d540a3e00084ef978
Deploy Preview https://deploy-preview-4780--ngrx-io.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify[bot] avatar May 13 '25 23:05 netlify[bot]

Deploy Preview for ngrx-site-v19 ready!

Name Link
Latest commit 48c6aeb115b2652ceb4927d32c1ff8492f9ca39f
Latest deploy log https://app.netlify.com/projects/ngrx-site-v19/deploys/6893d38dad1d0d0008634698
Deploy Preview https://deploy-preview-4780--ngrx-site-v19.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify[bot] avatar May 13 '25 23:05 netlify[bot]

@timdeschryver @rainerhahnekamp since you two coached me in the issue

I tweaked the example code comments a little.

I added the block towards the end of the "Core Concepts > Defining Store Methods" as this pertains to both withMethods and withComputed which by then are both explained.

michael-small avatar May 13 '25 23:05 michael-small

Hi @michael-small,

Still interested in adding this tip to the FAQ page?

markostanimirovic avatar Jun 29 '25 02:06 markostanimirovic

Yeah @markostanimirovic, I was curious about what I think can be agreed upon since 3 maintainers all had their own takes. But I didn't want to ping everyone when you guys were working hard on a release.

Thoughts?

I like rainerhahnekamp's take on that - showing option B but giving a passing mention of option A in text. That seems inline from how I am reading everyone's take on this - emphasizing option B, but having some mention of option A.

Additionally, move this to an FAQ point.

So to the FAQ for sure, but the former point I was wondering about before fleshing out the next iteration of the tip

michael-small avatar Jun 29 '25 02:06 michael-small

@markostanimirovic @timdeschryver @rainerhahnekamp

I did the following after making some assumptions on what would work well between everyone's takes:

  • Moved the tip to the FAQ
  • With respects of "Option A" (two consecutive feature blocks)
    • Removed a showcase of "A" in code
    • Mentioned that "A" was possible in text, but took the opportunity to say why it is not encouraged
  • Streamlined the example by removing sortBooks.
  • Adjusted the example to be concisely about a computed that is returned but also a computed made from that one in the same scope
    • Perhaps it is a bit contrived, but I think it is more concise and easy to follow
    • I didn't want to stray too far from the type of example that was workshopped starting in the issue. However, if this example as it is now seems off then I can rework it to be something else

michael-small avatar Jul 09 '25 03:07 michael-small