consumeContext
consumeContext<
T>(host,context,onChange?):ContextConsumption<T>
Defined in: packages/webcomponents/src/consumeContext.js:29
Subscribe to a context value on a host element using the framework-agnostic Context Protocol.
Unlike @lit/context’s ContextConsumer, this needs no
ReactiveControllerHost — it works on a bare HTMLElement, so a plain custom
element can consume a block/config provided by any protocol-speaking ancestor
(Lit or otherwise). The onChange callback fires synchronously on request()
if a provider answers, and again whenever a subscribed provider’s value
changes.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”HTMLElement
The element that dispatches the request.
context
Section titled “context”The context key to request.
context
Section titled “context”T
onChange?
Section titled “onChange?”(value) => void
Called with each new value.
Returns
Section titled “Returns”ContextConsumption<T>
