How to extend ElementView in TS? #1817
-
I have a custom class MyElement extends dia.Element {
myModelMethod() {...}
}
class MyElementView extends dia.ElementView {
myMethod() {
this.model.myModelMethod(); // myModelMethod is unknown but works
}
} However if you use |
Beta Was this translation helpful? Give feedback.
Answered by
kumilingus
Sep 23, 2022
Replies: 1 comment 1 reply
-
You can redefine properties and methods in your custom view if needed. class MyElement extends dia.Element {
test() { return; }
}
class MyElementView extends dia.ElementView {
model: MyElement;
}
const view = new MyElementView();
view.model.test(); Ideally, the ElementView should be a generic class. This could be perhaps changed to: class ElementView<T extends Element = Element> extends CellViewGeneric<T> {
} But more testing would have to be done to make sure it's not a breaking change (See this for more info). |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
igo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can redefine properties and methods in your custom view if needed.
Ideally, the ElementView should be a generic class. This could be perhaps changed to:
But more testing would have to be done to make sure it's not a breaking change (See this for more info).