vuejs / vue-rx

👁️ RxJS integration for Vue.js.
MIT License
3.35k stars 190 forks source link

How to init vuerx to vue3 #148

Open ElBidouilleur opened 2 years ago

ElBidouilleur commented 2 years ago

Hi

How initialize vuerx in vue3 because the old version Vue.use not work in vue3 When I write app.use because app.use want Plugin_2 properties

import {createApp} from 'vue'
import {router} from "./utils/Router";
import App from "./App";

import translation_fr from './i18n/fr.json';
import translation_en from './i18n/en.json';
import {createI18n} from "vue-i18n";
import ClientSocket from "./sockets/ClientSocket";
import VueSocketIO from "vue-socket.io-extended";
import VueRx from "vue-rx";

const app = createApp(App)

const socket = ClientSocket.connect('http', '192.168.1.159', '3000');

const i18n = createI18n({
    locale: navigator.language.split('-')[0],
    fallbackLocale: 'fr',
    messages: {
        fr: translation_fr,
        en: translation_en
    }
})

app.component('App', App);

app.use(router);
app.use(i18n);
app.use(VueRx());
app.use(VueSocketIO, socket);

app.mount('#app')

Do you have an solution

Thanks

doommm commented 1 year ago

I suggest using @vueuse/rxjs instead in vue3

kormosp commented 6 months ago

I suggest using @vueuse/rxjs instead in vue3

Did this work to anybody instead vue-rx? I get the same error:

vue-rx.esm.js:310 Uncaught TypeError: Vue.use is not a function
    at vue-rx.esm.js:310:7
    at custom-ui.js:2:241
    at custom-ui.js:3:3

package.json

"vue": "^3.4.19",
"rxjs": "^6.6.7",
"vue-rx": "^6.2.0",
"vuex": "^4.1.0"

"devDependencies": {
"@vitejs/plugin-vue": "^5.0.4",
"@vue-macros/reactivity-transform": "^0.4.3",
"@vue/compiler-sfc": "^3.4.19",
"vite": "5.1.1",
"vite-plugin-static-copy": "^1.0.1"
},
import { createApp } from 'vue';
import Vue from 'vue';
import custom from "./custom.vue";
import VueRx from 'vue-rx';

const app = createApp(custom);
app.use(VueRx);
app.mount('#app')
doommm commented 6 months ago

I suggest using @vueuse/rxjs instead in vue3

Did this work to anybody instead vue-rx? I get the same error:

vue-rx is incompatible with vue3 because vue3 didn't have Vue.use API(app.use). And it's recommended to use Composition API in vue3. So i recommend using VueUse.

see this document for more information: https://vueuse.org/functions.html#category=%40RxJS