import { Client, Config, DeepPartial } from 'jovo-client-web';
import { PluginObject } from 'vue';

declare module 'vue/types/vue' {
  interface Vue {
    $client: Client;
  }
}

export interface JovoWebClientVueConfig {
  url: string;
  client?: DeepPartial<Config>;
}

const plugin: PluginObject<JovoWebClientVueConfig> = {
  install: (vue, config) => {
    if (!config?.url) {
      throw new Error(
        `At least the 'url' option has to be set in order to use the JovoWebClientPlugin. `,
      );
    }
    const client = new Client(config.url, config.client);
    // make the client reactive
    vue.prototype.$client = vue.observable(client);
  },
};

export default plugin;

export * from 'jovo-client-web';

import { Client, Config, DeepPartial } from 'jovo-client-web';
import { PluginObject } from 'vue';

declare module 'vue/types/vue' {
  interface Vue {
    $client: Client;
  }
}

export interface JovoWebClientVueConfig {
  url: string;
  client?: DeepPartial<Config>;
}

const plugin: PluginObject<JovoWebClientVueConfig> = {
  install: (vue, config) => {
    if (!config) {
      throw new Error(
        `At least the 'url' option has to be set in order to use the JovoWebClientPlugin. `,
      );
    }
    vue.prototype.$client = new Client(config.url, config.client);
  },
};

export default plugin;

export * from 'jovo-client-web';

--- 
+++ 
@@ -14,12 +14,14 @@
 
 const plugin: PluginObject<JovoWebClientVueConfig> = {
   install: (vue, config) => {
-    if (!config) {
+    if (!config?.url) {
       throw new Error(
         `At least the 'url' option has to be set in order to use the JovoWebClientPlugin. `,
       );
     }
-    vue.prototype.$client = new Client(config.url, config.client);
+    const client = new Client(config.url, config.client);
+    // make the client reactive
+    vue.prototype.$client = vue.observable(client);
   },
 };
 
:sparkles: Make Client reactive and add check if url is set in config
