Riley Lambert

Riley Lambert

1548820554

Is it a good approach to use firebase once method when retrieving all posts on ionViewWillEnter?

I am retrieving all posts (news) from firebase using the once method and showing it on the home tab (the first tab when the app is launched) :

get_all_posts(){

this.posts = [];
firebase.database().ref(‘/posts/’).once(‘value’).then(snapshot => {
… //rest of the code
}
}

This will be fired in the ionViewWillEnter():

ionViewWillEnter(){
this.get_all_posts();
}

In this case, get_all_posts method will be fired everytime the “home” tab is pressed right? which will get all posts again from the DB or for the entire session (from opening the app till closing the app running on the phone)the news retrieved from the first time only will be displayed?

#firebase #ionic

What is GEEK

Buddha Community

Poppy Cooke

1548824970

The news retrieved at first time with once() will fetch all the data from the reference you want to show, this will fetch the data just once and then detach the listener to the reference. When you press again your home button it will fetch again the data that belongs to that reference and will pull it from the database, if there is new content it will be displayed, if not, the first fetched data will be shown.

From your question

Is it a good approach to use firebase once method when retrieving all posts on ionViewWillEnter?* Yes, in my opinion, it is a good practice to just ask for the data once and then display it to the user, because if you use on() you will be always listening for new data and your home screen might be updated with new content before the user can see the first fetched news.

What is firebase,firebase bangla tutorial.

https://youtu.be/8BnVKuf1E5M

#firebase #firebase database #c# with firebase #c# with firebase tutorials #c# with firebase database #asp.net with firebase database

Riley Lambert

Riley Lambert

1548820554

Is it a good approach to use firebase once method when retrieving all posts on ionViewWillEnter?

I am retrieving all posts (news) from firebase using the once method and showing it on the home tab (the first tab when the app is launched) :

get_all_posts(){

this.posts = [];
firebase.database().ref(‘/posts/’).once(‘value’).then(snapshot => {
… //rest of the code
}
}

This will be fired in the ionViewWillEnter():

ionViewWillEnter(){
this.get_all_posts();
}

In this case, get_all_posts method will be fired everytime the “home” tab is pressed right? which will get all posts again from the DB or for the entire session (from opening the app till closing the app running on the phone)the news retrieved from the first time only will be displayed?

#firebase #ionic

Firebase Introduction with C#

https://youtu.be/7_1t_f3sNyc

#firebase #c# with firebase #firebase database #c# with firebase tutorials #c# with firebase database #asp.net with firebase database

Save Employee into firebase

https://youtu.be/_yBUW2JUM8Q

#firebase #firebase database #c# with firebase #c# with firebase database #c# with firebase tutorials #asp.net with firebase database

Create database into firebase

https://youtu.be/u3F3GCdBu08

#firebase #firebase database #c# with firebase #c# with firebase database #c# with firebase tutorials #asp.net with firebase database