Options
All
  • Public
  • Public/Protected
  • All
Menu

The builder injects an entry from a container into a Custom Element.

example

Inject an entry resolving its key from the property name

import {ElementBuilder} from "@tmorin/ceb-elements-core"
import {ContainerBuilder, ModuleBuilder} from "@tmorin/ceb-inversion-core"
import {InversionBuilder, InversionBuilderModule} from "@tmorin/ceb-inversion-builder"

// define the Custom Element
@ElementBuilder.get(TestElement).decorate()
class TestElement extends HTMLElement {
// inject the value of the registry matching the key "greeting"
@InversionBuilder.get().decorate()
greeting?: string

attachedCallback() {
this.textContent = this.greeting
}
}

// build the container
ContainerBuilder.get()
.module(new InversionBuilderModule())
.module(
ModuleBuilder.get().configure(() => registry {
// register the "greeting" value
registry.registerFactory<string>("greeting", () => "Hello, World!")
}).build()
)
.initialize()
.then(_ => document.body.appendChild(new TestElement()))

Type parameters

  • E: HTMLElement

Hierarchy

  • InversionBuilder

Implements

  • Builder<E>

Index

Constructors

Protected constructor

Properties

Static Private DEFAULT_CONTAINER

DEFAULT_CONTAINER: Container

Methods

build

  • build(Constructor: CustomElementConstructor<E>, hooks: HooksRegistration<E>): void

decorate

  • decorate(): PropertyDecorator

key

provider

Static get

Static setDefaultContainer

  • setDefaultContainer(container: Container): void

Generated using TypeDoc