Skip to content

LocalStorage Constructor is asyncronous #13

@WarrenWilkinson

Description

@WarrenWilkinson

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions