I am implementing a React - Reflux architecture based application, which shows a list of rows in a page. Each row in the list allows inline editing of the properties. The save button in the row, calls a reflux-action, which updates data to server.
So, for the forward flow this looks fine
rows/row/savebtn => reflux-action => reflux-store => server
Now, for refreshing the view
server => reflux-store => trigger => where???
I see 2 options:
server => reflux-store => trigger (list of rows) => rows
server => reflux-store => trigger (row changed) => row
The question is, who should be listening for store events? Should it be the rows component or an individual row that got updated.
I am tempted to use "rows" as the action response listener, but my concern is that "rows" should get entire page data so it can render. This means, I need to make an ajax call to get all rows from server, so that my display stays synchronised?
On the other hand, if I make the "row" as action listener, am I breaking the principle of 'single source of truth' coming from rows to row. Moreover, row component doesn't have a state, as it gets its row from its parent/owner like this
/**
* creates a HTML table to show requirements
**/
var ReqTable = React.createClass({
render: function() {
var rows = [];
rows = this.props.data.map(function(row) {
return ( <ReqRow key={row.id} row={row} />);
});
return (<div>{rows}</div>);
}
});
A record row is being created by sending a row data, which is read as this.props.row
in the child component.
What is the standard/preferred way to update the affected row in the rows table?