Open tlloliveira opened 1 year ago
Is your strorage created yet? That is an async function that takes some time. This doesn't seem like a bug to me, just the way it works.
I had some issues with it, because I used the storage indirecty in my auth-guard (via my auth-service), which is needed almost immediately. I solved it by initializing the storage-service in a provider:
In app.module.ts:
import { APP_INITIALIZER } from '@angular/core';
export function appInitializer(storageService: StorageService) {
return () => storageService.init();
}
Add this to the providers:
{
provide: APP_INITIALIZER,
useFactory: appInitializer,
multi: true,
deps: [StorageService]
}
You don't need to call this.init() in your storage constructor anymore.
I'm not sure if this is the best solution, but at least the entire app waits until the storage is created.
I think you're encountering this: https://github.com/ionic-team/ionic-storage/issues/229
yes, that looks like the same issue. Totally missed that, thank you.
Hello.
I'm using "@ionic/storage-angular": "^4.0.0" on the project. But, the method get return undefined.
The console shows: login storage.service.ts:31 undefined