Skip to content

Add ListView helper actions #10

Open
@andersevenrud

Description

@andersevenrud

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);
    }

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions