Reactive State Machines: Implementing a state machine as a 'stream of transitions'