Created
October 1, 2020 14:26
-
-
Save beatak/aa8dd01646c50b2a9e85b9401215fba8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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