@codehero/dynamic-class
v0.0.0
Published
Use decorator to generate class
Readme
@codehero/dynamic-class
Install
npm i @codehero/dynamic-class --saveTable of Contents
Feature
- 提更動態實例類別
Usage
Dynamic Class Decorator
使用添 @DynamicClass() 裝飾器,讓要動態實例的類別被記錄
import { DynamicClass } from '@codehero/dynamic-class';
@DynamicClass()
export class CustomClass implements Custom {
constructor(public property: string) {}
public method() { ... }
}使用 DynamicClassFactory 將指定的類別(以 String 給定類別名稱)實例
import { DynamicClassFactory } from '@codehero/dynamic-class';
const custom = DynamicClassFactory.createInstance<Custom>(
'CustomClass',
'custom-property',
);| Paramter | Type | Description | | --------- | ------ | -------------------------------------------- | | classNmae | string | 要實例的類別名稱 | | ...args | any[] | 實例該類別所需的建構值參數,根據實際數量添加 |
