App.svelte
<script>
import Nested from './Nested.svelte';
function handleMessage(event){
alert(event.detail.text);
}
</script>
<Nested on:message={handleMessage} />
Nested.svelte
<script>
import {createEventDispatcher} from 'svelte';
const dispatch = createEventDispatcher();
function sayHi(){
dispatch('message', {
text: 'Hi!'
});
}
</script>
<button on:click={sayHi}>
Click to say Hi!
</button>