Replies: 4 comments 4 replies
-
I will try migrating Text with abstract class |
Beta Was this translation helpful? Give feedback.
-
Hi @ShaMan123, What did I do
|
Beta Was this translation helpful? Give feedback.
-
The issue with abstract classes is that in JS they are just classes. It would be interesting if mixin can create flat classes like the old fabricJS in which mixins were just a developer driven concern of splitting files and nothing more. I think the flat classes are also, let's say, slower because are crate dynamically or at runtime. |
Beta Was this translation helpful? Give feedback.
-
I have been thinking how to migrate complex modules like Text/Canvas/Object and their mixins.
The difficulty is that the base class and the mixins are tangled together, cross referencing each others methods.
Some mixins are well defined and can be made as subclasses like @asturur did with ObjectGeometry (super class) and ObjectInteractivity (subclass).
Other mixins are tangled...
I think of using abstract classes to bridge the tangle by defining an abstract super class that all derived classes will extend and implement partially. Then we chain them together (preferably by extending) and produce the final mixed class.
Using abstract classes is correct IMO since this mixins are abstract and so are the objects they mix since none are standalone.
Output
Compiler Options
Playground Link: Provided
Here you can see A and B are astrange to each other, C extends A and is mixed with B.
TS doesn't approve, JS does.
Output
Compiler Options
Playground Link: Provided
Beta Was this translation helpful? Give feedback.
All reactions