Let's take a look at this:
protected getSettingByKey(key: string) : string {
let ret = null;
let api : BrowserAPI = Browser.getCurrentBrowserAPI();
let setting = api.readSetting(this.getUUID() + "." + key, "true", (value:string) => {
ret = key;
});
while (true) {
if (ret != null) return ret;
console.log("KEY IS NULL, SKIPPIN");
}
}
This is a function that reads the browsers native data storage for settings and MUST block until the function readSetting()
returns something.
I tried the above approach but it ends up being a dead loop.
I repeat, the function MUST, by all means BLOCK, it must NOT have any callback.
How to realize that?
I know this is an anti-pattern but that's the way it has to be.