February 2019
Beginner
694 pages
18h 4m
English
As a final test of our DI framework, let's now inject the MailServiceDi class into another class. This means that our new class will be dependent on the IMailServiceDi interface, which is itself dependent on the ISystemSettings interface. This is an example of a recursive dependency tree.
We start by defining an interface for the MailServiceDi class itself, as follows:
export interface IMailServiceDi {
sendMail(to: string, subject: string, content: string)
: Promise<void>;
}
export class IIMailServiceDi { }
Here, we have taken the definition of the sendMail function, which returns a Promise, and created an interface named IMailServiceDi. We have also created the class that will be used as a type lookup by our DI framework, ...
Read now
Unlock full access