Function: releaseQuietly()
API / @xmachines/core / utils / releaseQuietly
function releaseQuietly(release, onFailure): void;Defined in: packages/core/src/utils/release-quietly.ts:23
Runs one release, and it contains a failure of that release.
A teardown often runs several releases in a row, and each one can be code of a caller
that throws. A throw from the first release then skips every release after it, and the
owner holds a half teardown that no caller can complete. Run each release through this
function, and each one stands alone: a failure goes to onFailure, and the next
release runs.
Parameters
| Parameter | Type | Description |
|---|---|---|
release | (() => void) | null | undefined | The release to run. null and undefined do nothing, so a field that holds no release yet needs no check at the call. |
onFailure | (failure) => void | Receives the value that the release threw. It reports the failure, for example with console.error, and it must not throw itself. |
Returns
void
Example
import { releaseQuietly } from "@xmachines/core/utils";
const report = (failure: unknown) => console.error("a release threw", failure);for (const release of releases) releaseQuietly(release, report);