I find it necessary to distinguish between React and Flux, both of which implement a unidirectional data stream. I will only touch React here.
In Angular, modifying the DOM will directly mutate the value of the related sphere variables in your controller thanks to Angular's two-way data binding and digest loop. These are two ways, because, of course, any change in your controller is also directly reflected in the view attached to it.
Think of Angular as a Controller <--> View
In React, a component always displays the DOM based on its props and internal state. The React component can listen to the event that was fired in the DOM, which it displayed, which may seem a bit like a two-way data stream on its face, but there is an important difference: an event fired on the DOM does not update the internal state of the component. The component must listen to the event, and then explicitly update the component with the new state. This state change then triggers the DOM for reprocessing (if necessary). Thus, the components of props and status are the only source of truth and always control the output of the DOM. Of course, changes to the DOM can affect the component, but this is done indirectly.
Think of it as Component State --> DOM --> New Component State --> New DOM
djskinner
source share