February 2019
Beginner
694 pages
18h 4m
English
The examples we have seen so far are all class decorators. Remember that a decorator function will automatically be called by the JavaScript runtime when the class is declared. Our decorator functions up until this point have all been defined to accept a single parameter named constructor, which is of type Function. The JavaScript runtime will populate this constructor parameter automatically for us. Let's delve into this parameter in a little more detail.
Class decorators will be invoked with the constructor function of the class that has been decorated. As an example of this, consider the following code:
function classConstructorDec(constructor: Function) { console.log(`constructor : ${constructor}`); } @classConstructorDec ...Read now
Unlock full access