[]previous and next page

runWithEvent

Runs callback with event as the current request event.

Runs callback with event as the current request event.

Import#

ts
import { runWithEvent } from "@shadow-js/dusk/server";

Signature#

ts
function runWithEvent<T>(event: RequestEvent, callback: () => T, enabled = true): T

Parameters#

Name Description
event The event.
callback The work.
enabled Pass false to run without the context (the explicit-event fallback).

Returns#

Whatever callback returns.

Examples#

ts
runWithEvent(event, () => getRequestEvent() === event); // true where AsyncLocalStorage exists