Skip to content

Conversation

@rainerhahnekamp
Copy link
Contributor

@rainerhahnekamp rainerhahnekamp commented Nov 15, 2025

Align signalMethod and rxMethod with Angular’s resource/linkedSignal pattern so callers can pass a lazy () => T instead of creating an intermediate computed signal.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

Closes #4986

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[x] No

@netlify
Copy link

netlify bot commented Nov 15, 2025

Deploy Preview for ngrx-io ready!

Name Link
🔨 Latest commit 21c7312
🔍 Latest deploy log https://app.netlify.com/projects/ngrx-io/deploys/6920bc77dd47920008e7dd86
😎 Deploy Preview https://deploy-preview-4996--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
Copy link

netlify bot commented Nov 15, 2025

Deploy Preview for ngrx-site-v19 ready!

Name Link
🔨 Latest commit 21c7312
🔍 Latest deploy log https://app.netlify.com/projects/ngrx-site-v19/deploys/6920bc771c14d0000805db52
😎 Deploy Preview https://deploy-preview-4996--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.

config?: { injector?: Injector }
): EffectRef => {
if (isSignal(input)) {
if (typeof input !== 'function') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched the if condition to eliminate the possibility of a function in the else condition.

With Input | (() => Input) and a `typeof input === 'function', TypeScript would not narrow done the type union.

The `rxMethod` is a standalone factory function designed for managing side effects by utilizing RxJS APIs.
It takes a chain of RxJS operators as input and returns a reactive method.
The reactive method can accept a static value, signal, or observable as an input argument.
The reactive method can accept a static value, a reactive computation (like a Signal), or observable as an input argument.
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 am using the term "reactive computation" instead of auto-tracking functions because that's what the Angular team calls it in linkedSignal.

@rainerhahnekamp rainerhahnekamp force-pushed the signals/feat/auto-tracking branch from 25e40aa to 3fd0f9f Compare November 15, 2025 16:43
@rainerhahnekamp rainerhahnekamp marked this pull request as ready for review November 15, 2025 16:44
@rainerhahnekamp rainerhahnekamp marked this pull request as draft November 15, 2025 18:52
…xMethod` (#4986)

Align signalMethod and rxMethod with Angular’s resource/linkedSignal pattern
so callers can pass a lazy () => T instead of creating an intermediate
computed signal.

Closes #4986.
@rainerhahnekamp rainerhahnekamp force-pushed the signals/feat/auto-tracking branch from 3fd0f9f to 6074704 Compare November 15, 2025 18:53
@rainerhahnekamp rainerhahnekamp marked this pull request as ready for review November 15, 2025 19:32
# SignalMethod

`signalMethod` is a standalone factory function used for managing side effects with Angular signals. It accepts a callback and returns a processor function that can handle either a static value or a signal. The input type can be specified using a generic type argument:
`signalMethod` is a standalone factory function used for managing side effects with Angular signals. It accepts a callback and returns a processor function that can handle either a static value or a reactive computation, i.e. either a Signal or a function, which will be tracked automatically. The input type can be specified using a generic type argument:
Copy link
Member

Choose a reason for hiding this comment

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

To avoid explaining multiple times that the Signal is compatible with a computation function, wdyt about mentioning a computation function in addition to Signal? (the same comment for other sections where this was changed)

Suggested change
`signalMethod` is a standalone factory function used for managing side effects with Angular signals. It accepts a callback and returns a processor function that can handle either a static value or a reactive computation, i.e. either a Signal or a function, which will be tracked automatically. The input type can be specified using a generic type argument:
`signalMethod` is a standalone factory function used for managing side effects with Angular signals. It accepts a callback and returns a processor function that can handle either a static value, a signal, or a computation function. The input type can be specified using a generic type argument:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean I should also remove the example then? Otherwise, I don't see so many places where the docs become easier.
Should we really call it "computation function"? I used "reactive computation", because that's the offical Angular term: https://angular.dev/api/core/linkedSignal.

We could just say "reactive computation" without explanation, but I doubt that most people know what that is...

Copy link
Contributor

@michael-small michael-small Nov 18, 2025

Choose a reason for hiding this comment

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

For what it's worth, I was curious, and it turns out both names are used in varying contexts

https://github.com/search?q=repo%3Aangular%2Fangular+%22reactive+function%22&type=code

https://github.com/search?q=repo%3Aangular%2Fangular+%22reactive+computation%22&type=code

"reactive function" in form/effect/httpResource related stuff, and "reactive computation" in linkedSignal, one resource doc, and a couple primitive file/docs.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it's called differently depending on the API. The input argument of computed is named computation, and it's a function, so I think 'computation function' should be clear enough.

We could just say "reactive computation" without explanation, but I doubt that most people know what that is...

@rainerhahnekamp Agree. I'd keep mentioning signals for clarity.

Co-authored-by: Marko Stanimirović <markostanimirovic95@gmail.com>
rainerhahnekamp and others added 4 commits November 21, 2025 20:23
Co-authored-by: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com>
Co-authored-by: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com>
Co-authored-by: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com>
Co-authored-by: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@ngrx/signals: Support () => T in signalMethod and rxMethod

5 participants