Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49082

App initialization

$
0
0

Hi,

I have a generic question regarding initializing my app.
I see ppl using the app.component constructor to call a method like:

initializeApp() {
this.platform.ready().then(() => {
// do some stuff
}
}

Furthermore I saw projects using app.modules provider to declare:

{
provide: APP_INITIALIZER,
useFactory: initApp,
multi: true,
deps: [UserController]
},

and have the method also in app.module like:

export function initApp(controller: UserController) {
return () => {
return new Promise((resolve) => {
controller.loadUser();
resolve();
});
};
}

Could you please elaborate what are the main difference, and when to use which way? Or are there any other ways to initialize my app?
Standard use case I would like to do: load the user object from the local storage.

Any help appreciated
thanks a lot!

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 49082

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>