Separating Workflow Orchestration from UI Reactions in Frontend Applications

https://hackernoon.imgix.net/images/qc0IcWKcfdgwZ5qmfnCwI7M9hTu1-j903be5.jpeg

State and Events

Front-end application architecture rarely becomes messy due to one bad decision. It usually happens gradually: a view-model imports a toast library, a modal component coordinates redirects, and a notification message becomes observable state. Over time, the logic becomes scattered across different layers, components, and view-models. The boundaries between layers start to blur.

But none of these decisions seem that bad on their own. The problem becomes apparent later when different view-models, components, and rendering logic manage a single workflow. This often happens because developers treat two distinct things as the same: state and events.

State is usually used for things that exist for a period of time: entities, loading states, filters, caches, etc. Events are different. They don’t exist — they happen: a login succeeds, a session expires, validation fails, etc. Something happens, another part of the application reacts to it, and then the event is gone....

Copyright of this story solely belongs to hackernoon.com. To see the full text click HERE