I have a main application that contains the user object and the login component
<script>
let user = {}
</script>
hello {user.username}
<login user={user} />
In the login component, I make a call to ajax and receive some data like:
user = {id:1, username:"john"}
How can I then "inform" the main application I have updated the user so it displays hello john
For now, I dispatch an event
import { createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher();
Is there a better way to achieve that ?