O'Reilly logo

Mastering TypeScript by Nathan Rozentals

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required