I have created custom service instances in main.ts
app.config.globalProperties.$service1 = new Service1();
app.config.globalProperties.$service2 = new Service2();
While I can use these instances inside Vue components, I also want to be able to utilize them in utility files.
In Vue 2, this was achieved through:
import Vue from "vue";
Vue.prototype.$service1.someMethod("foo");
The only method that worked for me was exporting the app
instance in main.ts
and importing it in my utility files, but this solution didn't feel quite right.
So, what is the equivalent of Vue.prototype
in Vue 3?
How can I maintain singleton behavior and still access the instances outside of Vue components?