-
-
Couldn't load subscription status.
- Fork 2k
Open
Labels
Description
Which @ngrx/* package(s) are relevant/related to the feature request?
signals
Information
Problem
With Angular's resource and linkedSignal, we saw that the Angular team moved having a parameter of Signal<T> to () => T. This makes sense because users don't have to create an intermediate computed signal just to pass complex values, and the tracking will be done internally.
Right now, with signalMethod or rxMethod, users need to do the following:
const printName = signalMethod<{
firstname: string;
lastname: string;
}>(console.log);
const firstname = signal('John');
const lastname = signal('Doe');
const name = computed(
() => ({ firstname: ${this.firstname()}, lastname: ${this.lastname()} })
);
printName(name);Proposed Solution
const printName = signalMethod<{
firstname: string;
lastname: string;
}>(console.log);
const firstname = signal('John');
const lastname = signal('Doe');
printName(() => ({ firstname: ${this.firstname()}, lastname: ${this.lastname()} }));Advantages
- Follows Angular's pattern:
resourceandlinkedSignalboth use() => T - Less boilerplate: No intermediate computed signals needed
- Backward compatible: Signals have the same signature as
() => T
Describe any alternatives/workarounds you're currently using
I have to create the computed manually.
I would be willing to submit a PR to fix this issue
- Yes
- No