October 2017
Intermediate to advanced
548 pages
13h 23m
English
Since we are going to an event-listener model, the controller no longer needs to directly know which UI elements to update each time the user steps through the instructions data. Delete the declarations for stepText, titleText and bodyText.
Then we can replace CurrentInstructionUpdate() with the following, much simpler, code that invokes our event by calling OnInstructionUpdate.Invoke():
private void CurrentInstructionUpdate() {
InstructionStep step = currentInstructionModel.GetInstructionStep(currentStep);
OnInstructionUpdate.Invoke(step);
}
Now, whenever the controller wants to update the screen, it invokes our OnInstructionUpdate event.
Read now
Unlock full access