Create a state machine that transitions based on events
The initial state
Object mapping states to event handlers
Object with current state and unsubscribe function
Create a state machine that transitions based on events