Angular · Senior · Question 9 of 75
When would you pass a custom equal function to a signal?
user = signal<User>(initial, { equal: (a, b) => a.id === b.id && a.version === b.version });- ✓Correct answer: To skip notifying dependents when a new object is semantically equal to the old one
- 2To make the signal deep-freeze its value
- 3To compare the signal with values from the server
Explanation
By default signals use Object.is, so every new object triggers updates. A custom equality avoids recomputation and re-rendering when a refetch returns the same data.