Read https://www.infoq.com/articles/robust-user-interfaces-with-state-machines/