how to access app.config.globalProperties
withing <script setup lang="ts">
?
I have looked around for several approaches: like this SO post, and tried to combine elements below:
\\ main.ts
import mitt from 'mitt'
const emitter = mitt()
declare module '@vue/runtime-core' {
export interface ComponentCustomProperties {
emitter: typeof mitt
}
}
app.config.globalProperties.emitter = emitter
tried packaging for use in composition-api .. no luck either
\\ bus.ts
import { getCurrentInstance } from 'vue'
const app = getCurrentInstance()
const bus = app.appContext.config.globalProperties.emitter // app is undefined
export const useBus = () => ({ bus })