Skip to content

Instantly share code, notes, and snippets.

@beatak
Created October 1, 2020 14:26
Show Gist options
  • Save beatak/aa8dd01646c50b2a9e85b9401215fba8 to your computer and use it in GitHub Desktop.
Save beatak/aa8dd01646c50b2a9e85b9401215fba8 to your computer and use it in GitHub Desktop.
<script>
import Controller from './game/Controller.svelte';
function handleGlobal (ev) {
console.log('handleGlobal on App!');
console.log(ev);
}
</script>
<h1>Hello!</h1>
<Controller></Controller>
<svelte:window on:global={handleGlobal}></svelte:window>
<script>
function handleClick() {
const ce = new CustomEvent('global');
ce.data = {a : 'b'};
window.dispatchEvent(ce);
}
</script>
<button on:click={handleClick}>Global event!</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment