qmuntal / stateless

Go library for creating finite state machines
https://wikipedia.org/wiki/Finite-state_machine
BSD 2-Clause "Simplified" License
972 stars 53 forks source link

Triggers and state transitions with multiple conditions #90

Open claes opened 6 days ago

claes commented 6 days ago

I have difficulty to wrap my head around how to use stateless to model a simple case.

Let's say I want a state machine to control if a lamp should be turned on or off. A home automation case, when there are sensors that can detect conditions.

It should be turned on if I am home and it is dark outside, and it should turned off otherwise. So if I am home and it becomes evening, it should turn on, but if I leave, it should turn off.

So there are two conditions that need to be evaluated together if to transition.

How would this best be modelled with stateless?