title: Call Svelte component's function from global scope
body: <p>I am creating a Sapper page, where I'd like to use <a href="https://developers.google.com/identity/sign-in/web/sign-in" rel="noreferrer">Google Sign-in button</a>. It requires <code>data-onsuccess</code> attribute to specify callback function. From what I was able to discover from Google's platform JS library, it looks for the function in the global/<code>window</code> scope.</p>
  
  <p>Is there a way to access/call Svelte's component function from global webpage scope? It might be of use for interop with external libraries which cannot be loaded through <code>import</code> right into the component.</p>
  
  <p>Example of what I am trying to do:</p>
  
  <pre><code>&lt;script&gt;
    function onSignComponent(user){
      console.log('Signed in');
    }
  &lt;/script&gt;
  
  &lt;div id="login" class="g-signin2" data-onsuccess="{onSignComponent}" data-theme="dark" /&gt;
  </code></pre>
  
  <p>This work when <code>onSignComponent</code> is in global scope but not when it is in component scope.</p>