Another Bypass-Style Solution:
instead of using this., you can use super..
- A prerequisite is to create two classes, one as a Base Class, another as a Usable Class.
- The Base Class contains the methods that you want to call in the constructor.
- The Usable Class calls the Method from within it's constructor using
super.myMethod();instead ofthis.myMethod();
This is a subtle benefit made easily possible thanks to Typescript. :)
Example:
Source: Typescript Bypass Solution on StackoverflowTypescript Bypass Solution on Stackoverflow
export class myBaseClass
{
constructor(ctx:any)
{
this.ctx = ctx; // Audio context saved into member variable of class
}
myBaseMethod()
{
// Do Complex Work
}
}
export class myUsableClass extends myBaseClass
{
constructor(ctx:any)
{
super(ctx);
super.myBaseMethod(); // Use super., Not this.
}
}