Description
Hello,
First of all, thanks for delivering this awesome plugin!
I am creating a Vue components package that under the hood uses vue-rx. The package is intended to be used as a plugin after publishing on npm. The problem is with vue-rx initialization. Components instantiated in client app are missing the features provided by vue-rx (for example methods like this.$createObservableMethod
are undefined and subscriptions
are not computed).
Currently, the package's entry point looks like this:
// main.ts at components package
import { PluginObject } from 'vue';
import VueRx from 'vue-rx';
import * as components from './components';
const RectiveComponents: PluginObject<never> = {
install(Vue): void {
Vue.use(VueRx);
Object.values(components)
.forEach(component => Vue.component(component.name, component));
},
};
export default RectiveComponents;
And I am trying to use it in an app:
// main.ts at app using the package
import Vue from 'vue';
import RectiveComponents from 'reactive-components';
Vue.use(RectiveComponents);
// example usage
Vue.extend({
template: '<ReactiveComponent ... />',
data() { ... }
}).$mount('#app')
I have also tried adding Vue.use(VueRx)
in the parent app, without no luck. RxJs is installed as a dependency on both projects.
As a side note, by adding the following lines to package's main.ts, the components work correctly (reactive methods are available etc.), but I am getting errors caused by Vue duplication.
// main.ts at components package
// ...
import Vue from 'vue';
Vue.use(VueRx);
const RectiveComponents: PluginObject<never> = { ... };
export default RectiveComponents;
I was wondering if maybe vue-rx could be used as a mixin, and be applied to each component, but I haven't found any info on that.
I'm running [email protected]
, [email protected]
and [email protected]
.
Big thanks in advance!