-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
service from documentation creates async bug at startup #229
Comments
Assuming my ticket, ionic-team#229, is a good solution to the issue I raised, this updates the documentation to use the new technique.
Thank you so much. This was driving me crazy. Please, someone update this in the documentation! |
Cool!! |
Thanks for pointing this out, as it was driving me nuts too with services relying on storage and it just wasn't working out. I thought I was missing something fundamental. It looks familiar, as basically just you have to create your own
is just the same as:
For |
We had the same issue, thank you @rtpHarry. Hopefully the improvement to the docs can be merged soon. |
This solution works for me
|
Fixes "exposing storage service example" from ionic-team#229
Your solution is working fine for now. In my case, I have For now, I do not see any consequence of this. |
From my testing of the example service in the documentation, it seems that it contains a bug.
The constructor calls
init()
withoutasync
(because it's not supported in a constructor):However, that means that if your app is relying on the storage very early on, you are going to get back
undefined
from aget
.For me, I have a tutorial guard set up which checks if the tutorial has been completed to decide if it should show the homepage or redirect to the tutorial slider page. It was always showing the tutorial because the result was
undefined
.I've improved the service so that it takes a similar approach to the way that Ionic Storage is actually written; which is checking if the storage is initialised before trying to operate on it.
That way it can
await
the proper completion of the storage:The text was updated successfully, but these errors were encountered: