lit-ui-router / requestContext
Variable: requestContext
ts
const requestContext: <T>(target, key, options?) => ContextType<T> | undefined;Defined in: packages/lit-ui-router/src/context.ts:264
Requests key from whichever provider answers on target, and returns the value a provider supplied synchronously.
The target is any EventTarget, not only an element. Returns undefined when nobody answered. Every answer reaches options.callback; the return value is the first one only.
Type Parameters
| Type Parameter | Description |
|---|---|
T extends UnknownContext | the context key's type, branded with the value it references |
Parameters
| Parameter | Type | Description |
|---|---|---|
target | EventTarget | the event target to dispatch the request from |
key | T | the context key to request, matched by identity |
options? | RequestContextOptions<T> | subscription and callback options |
Returns
ContextType<T> | undefined
Example
ts
import { requestContext, routerContext } from 'lit-ui-router/context';
const router = requestContext(element, routerContext);