isSuspension
Tells whether a caught value is the suspension sentinel rather than an error.
Tells whether a caught value is the suspension sentinel rather than an error. Use it in a custom
primitive's catch so a transition's held read is passed on instead of being reported as a
failure.
Import#
ts
import { isSuspension } from "@shadow-js/core/extend";
Signature#
ts
function isSuspension(value: unknown): boolean
Parameters#
| Name | Description |
|---|---|
value |
The caught value. |
Returns#
True when value is SUSPENSION.
Examples#
ts
import { isSuspension } from "@shadow-js/core/extend";
function attempt(run: () => void, onError: (error: unknown) => void): void {
try {
run();
} catch (error) {
if (isSuspension(error)) throw error;
onError(error);
}
}