Function: injection()
ts
function injection<T>(optionsOrInjectionId:
| InjectionOptions<T>
| ServiceIdentifier<T>): InjectionDecorator<T>;Defined in: src/wirestate-lit/consumption/injection.ts:84
Injects a container value into a Lit element property.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
optionsOrInjectionId | | InjectionOptions<T> | ServiceIdentifier<T> | Service token or options. |
Returns
Lit property decorator.
Remarks
The property follows the nearest container context unless once is true.
Examples
typescript
class MyElement extends LitElement {
@injection(MyService)
private myService!: MyService;
public render() {
return html`<div>${this.myService.getName()}</div>`;
}
}typescript
class MyElement extends LitElement {
@injection({ injectionId: MyService, once: true })
private myService!: MyService;
public render() {
return html`<div>${this.myService.getName()}</div>`;
}
}