title: Use onMessage.addListener's sendResponse asynchronously
body: <p>I am working connect a Chrome extension with a background script.
  For simple synchronous calls it works fine. I send a message and get a response.</p>
  
  <p>Apparently, the below <code>getValue</code>, which internally uses IndexedDB with Dexie promises, does not allow to use the simple <code>sendResponse</code>. I saw the way to deal with this would be to send message in response.
  However, for me, it does not really make sense. The background script simply checks whether the value a specific key is to be found in the database. Extension should just block until the value for the key is returned.</p>
  
  <p>Could I unroll this somehow to use <code>sendResponse</code>? Perhaps wrap <code>return findData()</code> into a synchronous function?</p>
  
  <pre><code>chrome.runtime.sendMessage({
    request:'getValue',
    key: shortcutKey
  }, (data) =&gt; {
    debugLog('getShortcut:', data);
    let value = data.value;
    console.log(`for key: ${key} found ${value}`);
    ...
    do_my_thing();
  });
  </code></pre>
  
  <p>Background script:</p>
  
  <pre><code>chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
    switch (request.name) {
      case 'getClipboard':
        sendResponse({clipboard:getClipboard()});
        break;
      case 'getValue':
        console.log(`background::getValue handler key:`, request.key);
        return findData(request.key.substring(constants.PREFIX.length)).then((result) =&gt; {
          console.log(`findData return: ${result}`);
          sendResponse( { value: result });
        });
        break;
        ...
    }
  });
  </code></pre>