-
-
Save cursosdesarrolloweb/8278e81de85a831522006238ae64f5cc 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
<template> | |
<h1>Blog</h1> | |
<button @click="globalEvent">Global Event</button> | |
</template> | |
<script> | |
import { inject } from "vue"; | |
export default { | |
name: "Blog", | |
setup() { | |
const emitter = inject("emitter") | |
const globalEvent = () => { | |
emitter.emit("blogLoaded", true) | |
} | |
return { globalEvent }; | |
} | |
} | |
</script> |
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
<template> | |
<h1>Products</h1> | |
</template> | |
<script> | |
import { inject, onMounted } from "vue"; | |
export default { | |
name: "Products", | |
setup() { | |
const emitter = inject("emitter") | |
onMounted(() => { | |
emitter.on("blogLoaded", (status) => { | |
console.log("blog loaded") | |
console.log(status) | |
}) | |
}) | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment