Skip to content

Commit

Permalink
Merge pull request #2 from cesarParra/perf-improvement
Browse files Browse the repository at this point in the history
Avoiding re-notifying on set if the value doesn't change.
  • Loading branch information
cesarParra committed May 24, 2024
2 parents c2c3e6d + df75fe9 commit 1087b4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions force-app/lwc/signals/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ function $signal(value) {
return _value;
}
function setter(newValue) {
if (newValue === _value) {
return;
}
_value = newValue;
for (const subscriber of subscribers) {
subscriber();
Expand Down
3 changes: 3 additions & 0 deletions src/lwc/signals/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ function $signal<T>(value: T): Signal<T> {
}

function setter(newValue: T) {
if (newValue === _value) {
return;
}
_value = newValue;
for (const subscriber of subscribers) {
subscriber();
Expand Down

0 comments on commit 1087b4d

Please sign in to comment.