[Vuejs]-How would a WebTorrent VueJS component could be build?

0👍

I will answer cause I found a solution. Then if the community wants this to be deleted, its all right.

Basically what I did is wait for a Component to be mounted.

Inside AComponent.Vue

<template>
  <keep-alive>
     <!-- HTML binding webtorrent client data -->
  </keep-alive>
</template>

<script>
  export default {
    mounted() {
      var client = WebTorrent()
    }
  }
</script>

Why this achieve what I was looking for ? :

  • keep alive keep that parts of the DOM alive, when i render another template and come back to this one (as if the download queue is in a widget, modal, or another view that needs to keep alive).
  • mounted, its part of the component lifecycle hooks (https://v2.vuejs.org/v2/guide/instance.html#Lifecycle-Diagram), and happens once the DOM has been maniuplated, window exists (needed by WebTorrent), and the component has been rendered.

Leave a comment