-1

When I load a list (for example user) it works very well however, every time I load this famous page, the whole list is reloaded by firebase is so uses a lot of data ...

How to load it only once during the session?

I have already tried to load the list once at the opening of the page in the TS but it still loads the data because of the ngIf in HTML ...

<ion-col col-12>

    <p>Pseudo : {{user.p}}</p>

</ion-col>

this.users = await this.database.list(`G/${this.myUid}/U/`).valueChanges().take(1);

I wish that when I open the page it loads the list the first time but when I close this page and I return later (in the same session) it does not reload the data but only that it me them posters

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

1 Answers1

0

The JavaScript SDK for the Firebase Database only keep data in memory. It doesn't keep data anywhere that persists between page reloads. When you reload the page, all memory of the previous page is lost. And that means that the data must be downloaded from the server again.

If you want to prevent this reloading, you'll have to implement your own offline persistence mechanism. There is a library angularfire-offline that implements disk persistence, but it's not an official Firebase library, and I've never tested with it.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807