DEV Community

Discussion on: State machine advent: Guard state transitions, guard actions (14/24)

Collapse
 
codingdive profile image
Mikey Stengel • Edited

Thank you for the comment. To keep the examples as simple as possible, they are indeed a bit contrived and do not represent a fully working thermostat in real life. I am indeed mixing the concept of a thermostat tracking the temperature and the temperature that is set by a user according to the explanation at hand. I'm sorry if this made the example more confusing. I did however give a hint to this inconsistency in the 13th post when I showed how context changes are driven by events from a component.

  return (
    <Sensor onChange={(e: {temperature: number }) => void send({ type: 
      SET_TEMPERATURE, temperature: e.temperature }) } />
  )

// or we let the user drive our context changes
  return (
    <input onChange={e => void send({ type: SET_TEMPERATURE, temperature: 
       e.target.value })} placeholder="Set the temperature." />
   )
Collapse
 
karfau profile image
Christian Bewernitz

I was indeed not aware oft the "Sensor" part, THX for the reply