The problem is that sometimes the “Loading” closes and the data (email and password) reset is not performed, nor the redirection, what happens is that it stays on the same page and nothing happens.
Is it correct the redirection (window.location.assign(’/’)) after set the data in Storage of @ionic/storage. ??
Be aware that all calls to Ionic storage return a Promise! Therefore, some value might not be written before your next line of code executes, so make sure the write operation is finished before doing the view transition.
Also I recommend to use the Angular router to replace your URL instead of using window directly. If you want to prevent users going back, simply add an option like this:
I recommend avoiding the self idiom, because it was intended for managing execution context before arrow functions were available. Use arrow functions and forget about self. If this is not what you expect, you’ve got a bigger problem that should be fixed.
Secondly, if loading is a component, don’t store loading components in controller properties, because doing so clouds ownership and invites bugs. If it’s an injected instance of LoadingController, then notice that dismiss also returns a Promise.
Thirdly, while I don’t fundamentally disagree with the premise of @saimon’s suggestion of waiting on writes, in practice I find it tedious and error-prone to follow religiously, so I instead follow the convention of only reading from storage once per app run, either at app startup or the first time that data is needed. I never use storage to communicate amongst parts of a running app: I use mutually injected services and Observables to do that. Therefore I can safely ignore when writes actually happen.