Skip to content

Commit

Permalink
Simplify the debounce function creation
Browse files Browse the repository at this point in the history
  • Loading branch information
YonatanKra committed Nov 2, 2020
1 parent 2988bd2 commit 960e6d0
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions components/list/src/vwc-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,13 @@ function debounce(
// @ts-ignore
MWCList.styles = [styleCoupling, mwcListStyle, vwcListStyle];

const debouncedLayout = debounce(function <T>(this: T, ...args: any[]) {
if (!this) {
return;
}
MWCList.prototype.layout(...args);
});
/**
* This component is an extension of [<mwc-list>](https://github.com/material-components/material-components-web-components/tree/master/packages/list)
*/
@customElement('vwc-list')
export class VWCList extends MWCList {
layout(updateItems?: boolean): void {
debouncedLayout(updateItems, 25);
constructor() {
super();
this.layout = debounce(super.layout.bind(this));
}
}

0 comments on commit 960e6d0

Please sign in to comment.