Concurrent Region
machine = StateMachine.create((g) => g
..initialState<MaintainAir>()
..state<MaintainAir>((b) => b
..state<MonitorAir>((b) => b
..onFork<OnBadAir>((b) => b
..target<HandleFan>()
..target<HandleLamp>()
..target<WaitForGoodAir>(),
condition: (s, e) => e.quality < 10))
..coregion<CleanAir>((b) => b
..state<HandleFan>((b) => b
..onEnter((s, e) async => turnFanOn())
..onExit((s, e) async => turnFanOff())
..onJoin<OnFanRunning, MonitorAir>(condition: ((e) => e.speed > 5))
..state<FanOff>((b) => b)
..state<FanOn>((b) => b
..onEnter((s, e) async => machine.applyEvent(OnFanRunning()))))
..state<HandleLamp>((b) => b
..onEnter((s, e) async => turnLightOn(machine))
..onExit((s, e) async => turnLightOff(machine))
..onJoin<OnLampOn, MonitorAir>()
..state<LampOff>((b) => b)
..state<LampOn>((b) => b
..onEnter((s, e) async => machine.applyEvent(OnLampOn()))))
..state<WaitForGoodAir>((b) => b..onJoin<OnGoodAir, MonitorAir>())))
..onTransition((s, e, st) {}));Last updated
Was this helpful?