Skip to content
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

LocalStorage Constructor is asyncronous #13

Open
WarrenWilkinson opened this issue Aug 16, 2021 · 0 comments
Open

LocalStorage Constructor is asyncronous #13

WarrenWilkinson opened this issue Aug 16, 2021 · 0 comments

Comments

@WarrenWilkinson
Copy link

The constructor calls an asyncronous function (but returns the new object -- the async is handled in the background and you lose your handle to it).

This is problematic, because I've got a boot up routine that instantiates a new LocalStorage, and then later (at some random future time) it'll report that it can't read the directory. But it's too late -- I never got a handle to that promise, so I can't capture the error. It just sits in the logs.

Instead, just make the constructor NOT call initialize. And make that the responsibility of the person who instantiated the class. That way I can capture the async result and hook up a .then to it.

(in my project I 'work around' this by calling initialize manually... so I'm basically just pretending the in-constructor call to initialize never happened, and doing it again so I can await it's result).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant