Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ListView helper actions #10

Open
andersevenrud opened this issue Dec 14, 2018 · 0 comments
Open

Add ListView helper actions #10

andersevenrud opened this issue Dec 14, 2018 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@andersevenrud
Copy link
Member

This came up in a conversation on Gitter. The ListView does not have any methods to manipulate rows, only set them ( setRows()).

Solution:

    addRow: row => state => ({rows: [...state.rows, row]}),
    removeRowByIndex: index => state => {
      const rows = state.rows;
      if (index >= 0) {
        rows.splice(index, 1)
      }
      return {rows}
    },
    removeRow: row => (state, actions) => {
      const foundIndex = rows.findIndex(r => r === row);
      return actions.removeRowByIndex(foundIndex);
    }
@andersevenrud andersevenrud added the enhancement New feature or request label Dec 14, 2018
@andersevenrud andersevenrud self-assigned this Dec 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant