-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from cesarParra/develop
Minor release
- Loading branch information
Showing
12 changed files
with
843 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { $signal, $computed, $effect } from "c/signals"; | ||
|
||
const anySignal = $signal(0); | ||
|
||
$computed( | ||
() => { | ||
anySignal.value; | ||
throw new Error("An error occurred during a computation"); | ||
}, | ||
{ | ||
onError: (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; | ||
} | ||
} | ||
); | ||
|
||
$effect( | ||
() => { | ||
throw new Error("An error occurred during an effect"); | ||
}, | ||
{ | ||
onError: (error) => { | ||
console.error("error thrown from effect", error); | ||
} | ||
} | ||
); |
Oops, something went wrong.