Hello! After updating my ionic project 2 RC0 I found several problems. One of them is that a listview that recibde firebase data takes several minutes to refresh, but if we look at the console, the data arrives quickly! Does anyone know why this happens?
SERVICIO
/**
[exercises description]
Get all exercises in the firebase database using observer
to detect when element has been added or modified.
*/
exercises(): Observable<any> {
return Observable.create(observer => {
var userId = this.fireAuth.currentUser.uid;
this.exercisesRef = this.userProfile.child(userId + '/exercises');
let listener = this.exercisesRef.on('child_added', snapshot => {
let data = snapshot.val();
data.id = snapshot.key;
console.log(data);
observer.next(data);
}, observer.error);
return () => {
this.exercisesRef.off('child_added', listener);
};
});
}
CONTROLLER
/**
[ngOnInit description]
This event fire any time when user access to the view
*/
ngOnInit() {
// get all exercises using an observer and add
// exercises using push method with the value
// retrieved of firebase
this.exerciseData.exercises().subscribe(exercise => {
this.exercises.push(exercise);
});
}
VIEW
<ion-item-sliding *ngFor="let exercise of exercises">
<ion-item (click)="exerciseTapped($event, exercise)">
{{exercise.Name}} <br/> <span class='exerciseDate'>{{exercise.Date}}</span>
<div class="item-note" item-right>
{{exercise.Pr}}
<span *ngIf="exercise.Type === 'Weight' ">Kg</span>
<span *ngIf="exercise.Type === 'Time' ">Min</span>
<span *ngIf="exercise.Type === 'Reps' ">Reps</span>
</div>
</ion-item>
<ion-item-options side="right">
<button ion-button color="danger" (click)="removeExercise(exercise)"><ion-icon name="md-trash"></ion-icon></button>
<button ion-button color="primary"><ion-icon name="md-ribbon"></ion-icon></button>
</ion-item-options>
</ion-item-sliding>
</ion-list>
Thanks in advanced