Skip to content

Commit

Permalink
Updating example to take into account the previous value
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarParra committed Dec 6, 2024
1 parent b43f1e7 commit 2d09e5a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion examples/demo-signals/lwc/demoSignals/error-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ $computed(
throw new Error("An error occurred during a computation");
},
{
errorHandler: (error) => {
errorHandler: (error /*_previousValue*/) => {
console.error("error thrown from computed", error);
// Allows for a fallback value to be returned when an error occurs.
return 0;

// The previous value can also be returned to keep the last known value.
// return previousValue;
}
}
);
Expand Down

0 comments on commit 2d09e5a

Please sign in to comment.