February 2019
Beginner
694 pages
18h 4m
English
The last step in the implementation of the State and Mediator design pattern is to trigger the change of the state. This trigger could be purely within our code, or it could be as a result of actions on our UI. To begin with, we will need to create a new instance of the Mediator class, and register our AppComponent class as the implementation for the IMediatorImpl interface, as follows:
export class AppComponent
implements IMediatorImpl
{
... existing code ...
mediator: Mediator = new Mediator(this);
Here, we are specifying that the AppComponent class implements the IMediatorImpl interface, and are then defining a local variable named mediator. This local variable calls the Mediator constructor, passing in this (our
Read now
Unlock full access