Hi,
Can you tell me why below functionality has huge delay on first-time load? On 2nd time where it is normal.The same delay is on the actual device too.Please see the attached video.
Note : The issue here is firebase bind “this.eventData.getEventList().on(‘value’, snapshot => {}” When I remove it all are working fine.Do you know how to do it differently?
Video: Video about this issue
.html
<ion-card *ngFor="let event of eventList" (click)="goToEventDetail(event.id)" color="secondary">
<ion-card-content>
<p>Event Name: <strong>{{event?.name}}</strong></p>
<p>Ticket: <strong>${{event?.price}}</strong></p>
<p>Cost: <strong>${{event?.cost}}</strong></p>
<p>Date: <strong>{{event?.date}}</strong></p>
</ion-card-content>
</ion-card>
.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { EventDetailPage } from '../event-detail/event-detail';
import { EventData } from '../../providers/event-data';
@Component({
selector: 'page-event-list',
templateUrl: 'event-list.html',
})
export class EventListPage {
public eventList: any;
constructor(public navCtrl: NavController, public eventData: EventData) {
}
ionViewDidEnter() {
this.eventData.getEventList().on('value', snapshot => {
let rawList = [];
snapshot.forEach(snap => {
rawList.push({
id: snap.key,
name: snap.val().name,
price: snap.val().price,
cost: snap.val().cost,
date: snap.val().date
});
});
this.eventList = rawList;
});
}
}