Hi!
I’m designing an app and a big doubt came up to me. In my app most of its pages modifies/updates content of the user. Some of this pages are only for show information but in others the user can do certains things that may updated some of his attributes. An user object looks like:
{
"id":1,
"name": "David Corral Plaza",
"weight": "62",
"height": "174",
"gender": "male",
"status_feed": [],
...
}
So, imagine that I have this pages:
HomePage —> just shows info
Page1 —> Can modify certains attributes of the user
Page2 —> Also can modify certains attributes of the user
What I actually have coded is that, each time that I enter into some of this pages that can do updates (Page1, Page2), I show a loader (from LoadingController) while I retrieve the user vía HTTP GET.
What I think that I should do is to make the HTTP GET in my app.component.ts file and, using a Singleton Provider, show it directly in any of this pages. With this technique I dont have to do the HTTP GET each time that I enter into a Page, I only have to do it once: when the app is starting. By the other hand, I would use HTTP UPDATE to make the changes into the server at the same time that I updating the Singleton object attributes, to reflect this changes in the other Pages of the app.
Which one do you think that is the ‘‘correct’’ way to perform this?
Thanks and regards!