我有两个抽象类,但是其结构是一样的,不同的是分别继承了不同的类,我要怎么简写这种情况。
export abstract class DivComponentsManager extends HTMLElement {
protected themeWatcher = themeWatcher
protected disposeFuncs: (() => void)[] = []
constructor() {
super()
}
abstract renderView(): Promise<void>
connectedCallback() {
this.renderView()
}
disconnectedCallback() {
this.disposeFuncs.forEach(func => func())
}
}
export abstract class ButtonComponentsManager extends HTMLButtonElement {
protected themeWatcher = themeWatcher
protected disposeFuncs: (() => void)[] = []
constructor() {
super()
}
abstract renderView(): Promise<void>
connectedCallback() {
this.renderView()
}
disconnectedCallback() {
this.disposeFuncs.forEach(func => func())
}
}