refactor(all): async/await

This commit is contained in:
Manu Mtz.-Almeida
2018-03-24 03:24:57 +01:00
parent ee1aaafd73
commit e20f76c3b1
10 changed files with 113 additions and 138 deletions

View File

@ -15,10 +15,9 @@ export class InfiniteScroll {
private thrPx = 0;
private thrPc = 0;
private scrollEl: HTMLIonScrollElement|null = null;
private scrollEl: HTMLIonScrollElement|undefined;
private didFire = false;
private isBusy = false;
private init = false;
@Element() private el: HTMLElement;
@State() isLoading = false;
@ -82,19 +81,14 @@ export class InfiniteScroll {
*/
@Event() ionInfinite: EventEmitter;
componentWillLoad() {
async componentWillLoad() {
const scrollEl = this.el.closest('ion-scroll');
return scrollEl.componentOnReady().then((el) => {
this.scrollEl = el;
});
if (scrollEl) {
this.scrollEl = await scrollEl.componentOnReady();
}
}
componentDidLoad() {
if (this.init) {
console.warn('instance was already initialized');
return;
}
this.init = true;
this.thresholdChanged(this.threshold);
this.enableScrollEvents(!this.disabled);
if (this.position === Position.Top) {
@ -103,7 +97,7 @@ export class InfiniteScroll {
}
componentDidUnload() {
this.scrollEl = null;
this.scrollEl = undefined;
}
@Listen('scroll', {enabled: false})