Reactive Dynamic Hierachical State Machine ( JS )