Page MenuHomeSealhub

registry.ts
No OneTemporary

registry.ts

// this class keeps a register of the types of components available
import { BlockComponent } from "./components/block";
import { Component } from "./components/component";
import { HeadingComponent } from "./components/heading";
import { ImageComponent } from "./components/image";
import { TextComponent } from "./components/text";
interface ComponentConstructor<T extends Component> {
new (...params: unknown[]): T;
}
export class Registry {
map: Record<string, ComponentConstructor<Component>>;
constructor() {
this.map = {
block: BlockComponent,
heading: HeadingComponent,
image: ImageComponent,
text: TextComponent,
};
}
registerComponent(
type: string,
class_name: ComponentConstructor<Component>
): void {
this.map[type] = class_name;
}
getComponent(type: string): ComponentConstructor<Component> {
return this.map[type];
}
}

File Metadata

Mime Type
text/x-java
Expires
Tue, Dec 24, 14:02 (1 d, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
557125
Default Alt Text
registry.ts (873 B)

Event Timeline