3 ms·
Shower thought I've had recently: would we not be better off modelling a UI as Actions, rather than states? Each action changes this part of the markup, makes t
by LAC-Tech 3y ago
Shower thought I've had recently: would we not be better off modelling a UI as Actions, rather than states? Each action changes this part of the markup, makes these requests to app state / client DB / remote server.
This also maps better to a user centric conception of the app.
- notpachet 3y agoIf you ascribe to the unidirectional data flow philosophy a la Redux, then actions are just transformations between immutable state representations.
- ramesh31 3y agoYou've just described Redux/Flux
- LAC-Tech 3y agoThen my description isn't very good because I'm not imagining redux at all.
- lioeters 3y agoHere's how I model it: the view is a function of state; and actions create a new state, which re-renders the view. state -> view -> actions - | ^----------------------- Actions can be from the user via the view, but it can come from elsewhere, for example, websocket events. I like what another commenter said about a "stream of events", though in my mind an action is more limited than an event. An action has no event handlers, it can only dispatch state changes (or other actions).