title: AG-Grid with Redux
body: <p>In my job we decided to use <code>AG-Grid</code> in react variant: <a href="https://www.ag-grid.com/best-react-data-grid/index.php" rel="noreferrer">https://www.ag-grid.com/best-react-data-grid/index.php</a></p>
  <p>Currently, our architecture for <code>React</code> is <code>Redux</code>. From my little knowledge of <code>AG-Grid</code> I can say that it doesn't fit very well to this architecture. <code>AG-Grid</code> keeps it's overall state inside the component. It's cumbersome or even not clever to try to connect it to redux forcefully and completely.</p>
  <p>I can live with that but at least I need to watch for the row model changes - meaning fetches of new rows, sorts, filtering (I don't need to watch for cell changes). I have 2 ideas on how to watch for this and connect it to redux.</p>
  <p><strong>Option 1 - Use gridOptions.onModelUpdated()</strong></p>
  <p>With <code>gridOptions.onModelUpdated()</code> I know when filtering or sort was executed but I can't get to all rows displayed (<a href="https://www.ag-grid.com/angular-grid-model/" rel="noreferrer">docs</a>):</p>
  <blockquote>
  <p>State 1: Row Data</p>
  <p>API: There is no API to get this data. However it was provided by the application so you should already have it.</p>
  </blockquote>
  <p>Thus I can't dispatch a <code>redux</code> action as I don't have any data to update it with.</p>
  <p><strong>Option 2 - datasource.getRows()</strong></p>
  <p>I could dispatch actions with new rows. However, I haven't found any <code>onReset/onRowsDeleted/...</code> event, thus I don't know when to clear redux's <code>state.rows</code>. <strong>Update</strong> I can know that previous rows were cleared if argumernt <code>params</code> of <code>datasource.getRows(params)</code> is <code>params.startRow === 0</code>.</p>
  <p><strong>Question</strong></p>
  <p>Maybe I find a way how to use one of the 2 options but my question is:</p>
  <p>Are those good ideas to how connect <code>AG-Grid</code> to <code>Redux</code>?</p>