Skip to content

Commit

Permalink
Table: add setRowsSynced method
Browse files Browse the repository at this point in the history
Fixes #414.
  • Loading branch information
buschtoens committed Jul 7, 2017
1 parent 368fe02 commit 9b2d926
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions addon/classes/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,26 @@ export default class Table extends EmberObject.extend({
return this.get('rows').setObjects(Table.createRows(rows, options));
}

/**
* The same as `setRows`, however the given array is synced, meaning that
* mutating the array also updates the table and vice-versa.
*
* Also see `enableSync` in the constructor options.
*
* @method setRowsSynced
* @param {Array} rows
* @param {Object} options
* @return {Array} rows
*/
setRowsSynced(rows = [], options = {}) {
let _rows = RowSyncArrayProxy.create({
syncArray: rows,
content: emberArray(Table.createRows(rows, options))
});

return this.set('rows', _rows);
}

/**
* Push the object onto the end of the row array if it is not already present.
* @method addRow
Expand Down

0 comments on commit 9b2d926

Please sign in to comment.