Skip to content

Commit

Permalink
refactor(TableDataSource): improve default constructor arguments
Browse files Browse the repository at this point in the history
- Default the array passed into the ArrayDataSource and TableDataSource
to an empty array.
- Add arguments to TableDataSource constructor to set Filtering, Sorting,
and/or Paging to active or inactive
  • Loading branch information
pathurs committed Aug 2, 2018
1 parent 9377023 commit 5aab48c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/data-sources/array-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class ArrayDataSource<TEntry> extends DataSource<TEntry[]> {
*
* @param array The array.
*/
public constructor(array: TEntry[]) {
public constructor(array: TEntry[] = []) {
super(array);
}

Expand Down
11 changes: 9 additions & 2 deletions src/data-sources/table-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,18 @@ export class TableDataSource<TRow> extends ArrayDataSource<TRow> {
/**
* Creates a new TableDataSource with the supplied array.
*
* @param array The array.
* @param array The original array.
* @param filtering Whether filtering should be active.
* @param sorting Whether the sorting should be active.
* @param paging Whether the paging should be active.
*/
public constructor(array: TRow[]) {
public constructor(array: TRow[] = [], filtering: boolean = true, sorting: boolean = true, paging: boolean = true) {
super(array);

this.filterProcessor.active = filtering;
this.sorterProcessor.active = sorting;
this.pagerProcessor.active = paging;

this.preprocessors.addProcessor(this.filterProcessor);
this.preprocessors.addProcessor(this.sorterProcessor);
this.preprocessors.addProcessor(this.pagerProcessor);
Expand Down

0 comments on commit 5aab48c

Please sign in to comment.