Fancy buttons updating

Button with states.

The Button
Button is dummy. It has no knowledge about what the world is, but it happily takes in commands to be "red" or "blue" and can show what ever label is told to show.
Only thing it does know is that it must react when you click on it.

The state.
The state is property of something. Mostly boolean (day - night) but why not more (morning - day - evening- night)
The button with states does not own the state. But represents the state. So it can "blue" when state is "night" and "yellow" if state is "day".

State -> Button.
The state must be told to button. Button can't ask for state. Also as the button is dummy, it can't remember the state.

The Event
When day turns to night.
When dashboard connects to server side. (when you change tabs on dashboard)
Those events are triggers which must be feed to the logical part of flow where the state is determined and then sent to the button.

Button click changes the state
That is an event which itself has no connection to all of above but as the result of this event, another thing happened - the state changes. Look at the Event.

In your flow it looks like this

The fancy part is ui_control node. This does most of the hard work for you. It fires an event when (any) dashboard connects. so the state can be determined and sent to the button.

1 Like