react-redux-grid icon indicating copy to clipboard operation
react-redux-grid copied to clipboard

Implement selectors

Open taco opened this issue 8 years ago • 1 comments

It would be nice if grid came with selectors out of the box.

We can consume them internally as well as export them for users.

Proposed Selectors

These were the selectors I was thinking would add most value, let me know if you can think of some others:

  • getCurrentRecords
  • getIsEditing
  • getIsLoaded
  • getPager
  • getSelectedRows
  • getTreeData

Implementation options

We have a couple of different ways we use the selectors. I've come up with two options, we can choose one or do both.

Option A

import { buildSelectors } from 'grid';

const gridKey = 'grid-1';

const selectors = buildSelectors(gridKey);

const mapStateToProps = state => ({
    selectedRows: selectors.getSelectedRows(state),
    isLoaded: selectors.getIsLoaded(state)
})

Option B

import { selectors } from 'grid';

const gridKey = 'grid-1';

const mapStateToProps = state => ({
    selectedRows: selectors.getSelectedRows(gridKey, state),
    isLoaded: selectors.getIsLoaded(gridKey, state)
})

taco avatar Feb 06 '17 19:02 taco

I think option A is nicer -- but I also think it would be cool if both worked?

The only one I think we should add to the selectors list is:

getEditor

bencripps avatar Feb 06 '17 19:02 bencripps