Comments (2)
Your example is attempting to update list
mutably, but the custom equality function doesn't handle mutable updates.
this.list.update((list) => {
list.push('a');
return list;
});
This call to update
returns the same instance of the array (after pushing a new item). This will call the custom equality function with the same instance of the array as arr1
and arr2
. Since the implementation compares arr1.length === arr2.length
it will return true
, which makes list
assume nothing has changed (and not propagate a notification).
from angular.
@alxhub thanks for your reply and explanation, which makes totally sense (embarrassing I didn't see that myself).
As a consequence, we must always provide a new instance for set()
and update()
for signals. After realising the issue, it is clear to me. Nevertheless, I think it would be helpful to add this to the Signal guide - it should be especially mentioned in the section Signal equality functions which was misleading me (I see that the example is to show that two different instances with the same content should be considered equal).
from angular.
Related Issues (20)
- viewTransition not working with eventCoalescing HOT 2
- No docs about how to test effects in component constructor HOT 7
- Pending APP_INITIALIZER doesn't trigger Hydration warning after APPLICATION_IS_STABLE_TIMEOUT HOT 3
- Creating a view inside an `effect` will track any signal reads that happen in the view HOT 6
- Some pages of angular.dev are missing content HOT 1
- Fixed peerDependency in @angular/compiler 17.2.1 to @angular/[email protected] causes peer depency conflicts in new projects HOT 1
- Add an option to keep double-quotes as " instead escaping them as "
- Tutorial editor fails with "SyntaxError: Unexpected token '<'..." HOT 2
- how to import referece of html in ts file? HOT 1
- bug(Zone.js): removing capture:true event listener breaks .on* event listeners HOT 2
- Container CSS Queries don't work with ::ng-deep HOT 3
- Multiple instances of the same @defered component are instantiated in a random order with esbuild (but not webpack) HOT 1
- Service Worker has a memory leak and crashes the tab
- $localize.locale is undefined HOT 5
- control-flow command freeze
- [SSR]: Server context features are missing from ng-server-context in v17.x HOT 2
- A typo in a SVG file HOT 1
- Wrong link on Pipes page HOT 2
- Add a `ngReset` event to `FormGroupDirective` HOT 2
- undefined also removes the class binding HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular.