Controlling a view flow with a state machine

State machines represent a mathematical model of computational behavior. The model can be in any one of a number of finite states at any given time. The model changes from state to state when initiated by a triggering event or condition.

State machines are very good at handling complex user interface flow through an application. Each state can represent a view shown to the user. User interactions serve as the triggering events that can be used to transition from one state to another.

We can use a state machine to control the user's flow through our program, instead of coding the flow in our controllers. We can also use state machines to manage long-running processes between sessions.

The state machine ...

Get AngularJS Services now with O’Reilly online learning.

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