The State Design Pattern

Our last task for this application is to control the various screen elements as users interact with our application. As a user navigates the application, we need to move from carousel panel 1 to carousel panel 2, and update screen elements, such as showing and hiding the left-hand side filter panel. In a large web application, there may be many screen elements, many different transitions, and things such as pop ups or masks that say "loading…" while our application fetches data from backend services. Keeping track of all of these elements becomes a difficult and time-consuming task, often leaving large swathes of if-else or switch statements in many different areas of our code, leading to a lot of direct DOM manipulation ...

Get Mastering TypeScript now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.