Hi!
I have created a provider that returns me firebase data using observable observer. When the data provider returns are added to a list using the push method.
The problem is not automatically adapts, but after a minute. If I change my view and back, the data if cool.
In the beta 11 version malfunctioned, but this version does not work the push
PROVIDER
/**
[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 = '8Zh8KkAs2LWwbIZVqeNSU1AynmI2';
this.exercisesRef = this.userProfile.child(userId + '/exercises');
let listener = this.exercisesRef.on('child_added', snapshot => {
let data = snapshot.val();
data.id = snapshot.key;
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);
});
}
anybody has idea?