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