DEV Community

loading...

Discussion on: What the hell is Reactive Programming anyway?

Collapse
johnkazer profile image
John Kazer

How would you fit state charts/machines into this? On the basis that libraries like XState allow you to use transitions to regulate UI app states.

Collapse
ryansolid profile image
Ryan Carniato Author

It's interesting. Because state machines/charts represent potential states, moments in time. They represent discrete snapshots (I realize charts can represent a range but it still holds as a specific moment in time). And then on event dispatch we transfer from one state to the next through a defined transformation.

So stepping back with a given sequence of state changes from inputs isn't unlike a coarse grain stream. You transform data through a series of inputs. The representation might differ but you are essentially driving defined paths through your state logic.

Each one feels like it could be seen as a reactive atom/primitive. It's the driving event system + the declarative representation that aligns. I can picture imperative systems with state machines I wouldn't call reactive, but I can also picture reactive systems living inside an otherwise non-reactive system and have the same categorization.

So it's more by the definition that when one calls a Promise a state machine. Reactive streams are similarly state machines. I'm not sure that signals are in that while they hold different values they generally only have a single observable state.

But this is my current thinking.