Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F996236
registry.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
873 B
Referenced Files
None
Subscribers
None
registry.ts
View Options
// 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
Details
Attached
Mime Type
text/x-java
Expires
Tue, Dec 24, 14:02 (21 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
557125
Default Alt Text
registry.ts (873 B)
Attached To
Mode
R130 jdd
Attached
Detach File
Event Timeline
Log In to Comment