Skip to content

Commit

Permalink
Remove ngDoCheck function from DataTable component
Browse files Browse the repository at this point in the history
It's no longer needed if we update the rows and options in the ngOnChanges function.
  • Loading branch information
jtomaszewski committed Sep 28, 2016
1 parent b63bc30 commit 16d2652
Showing 1 changed file with 1 addition and 34 deletions.
35 changes: 1 addition & 34 deletions src/components/DataTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
OnInit,
OnChanges,
QueryList,
DoCheck,
AfterViewInit,
IterableDiffer,
HostBinding,
Expand Down Expand Up @@ -47,7 +46,7 @@ import { StateService } from '../services/State';
</div>
`
})
export class DataTable implements OnInit, OnChanges, DoCheck, AfterViewInit {
export class DataTable implements OnInit, OnChanges, AfterViewInit {

@Input() options: TableOptions;
@Input() rows: any[];
Expand Down Expand Up @@ -116,42 +115,10 @@ export class DataTable implements OnInit, OnChanges, DoCheck, AfterViewInit {
}
}

ngDoCheck() {
if (this.rowDiffer.diff(this.rows)) {
this.state.setRows(this.rows);
this.onRowsUpdate.emit(this.rows);
}

this.checkColumnChanges();
}

ngOnDestroy() {
this.pageSubscriber.unsubscribe();
}

checkColumnChanges() {
const colDiff = this.colDiffer.diff(this.options.columns);

if (colDiff) {
let chngd: boolean = false;
colDiff.forEachAddedItem(() => {
chngd = true;
return false;
});

if (!chngd) {
colDiff.forEachRemovedItem(() => {
chngd = true;
return false;
});
}

// if a column was added or removed
// we need to re-adjust columns
if (chngd) this.adjustColumns();
}
}

adjustSizes() {
let { height, width } = this.element.getBoundingClientRect();
this.state.innerWidth = Math.floor(width);
Expand Down

0 comments on commit 16d2652

Please sign in to comment.