Essentially I'd like to do some setup work if my library classes are called. For example:
class Child extends Parent { //methods } I'd like to assign a function to be called when the Parent class is extended. I'd like to be notified somehow. Before it's about to happen (with the methods about to be attached as a parameter), or after with the Child class as a parameter.
I have an ES5 library I built that uses a factory function to create new classes, and in that function I do lots of setup work. I'd like to do all that same stuff but with the simplicity of the ES6 class syntax so developers using my library don't need to think anything special is going on and can think in terms of more straightforward classes.
Any help would be much appreciated.
Parentconstructor or have a method that child classes are forced to implement, such asonConstruct();where you can trigger a custom event. However, since you are hiding complexity behind magic, I don't think this is the way you want to go. If you have a factory that does certain setup, don't you think the people using your library should be aware of it? I would implement a method that every child executes after constructing - that will hint something goes on and people will be aware it's not just a "regular" class they're dealing with.