How do I convert a custom websocket client into a Vue plugin?

How do I convert a custom websocket client into a Vue plugin?

I'm currently using this WebSocket module which formats calls to a unique type of server that runs locally on the user's device.

I'm currently using this WebSocket module which formats calls to a unique type of server that runs locally on the user's device.

Here's an example of it being used: https://github.com/holochain/hc-web-client/blob/develop/index.html

I'm using it in each component like this:

methods: {
    getArticle(get_address) {
      connect("ws:localhost:8888").then(({ call, close }) => {
        const params = {
          article_addr: get_address
        };

    call("test-instance/articles/get_article")(params)
      .then(response => {
        this.handleGetResponse(JSON.parse(response));
        close();
      })
      .catch(error => {
        console.error(error);
        close();
      });
  });
}

Problem is, I have to open and close the connection within each method. Ideally, I want one global ws connection, and then make simple call()s in my methods.

Can I do that as is, or do I need to convert it to a plugin? How do I do that?

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

10 Best Vue Icon Component For Your Vue.js App

In this article, I will collect 10 Vue icon component to bring more interactivity, better UI design to your Vue application.

Collection of 10 Vue Markdown Component for Vue.js App in 2020

Markdown is a way to style text on the web. The 10 Vue markdown components below will give you a clear view.

Collection of 15 Vue Input Component for Your Vue.js App

Vue input component gives you a baseline to create your own custom inputs. It consists of a prepend/append slot, messages, and a default slot. In this article I will share 15 Vue input components to you.