EventEmitter based finite state machine