Skip to content

How to extend ElementView in TS? #1817

Answered by kumilingus
igo asked this question in Q&A
Discussion options

You must be logged in to vote

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).

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@igo
Comment options

Answer selected by igo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants