Skip to content

Tarektouati/vue-use-worker

Repository files navigation

Welcome to vue-use-worker 👋

Version License: MIT Twitter: tarektweeti

Web Worker API implemented as Vue.js composition functions

Install

# install with yarn
yarn add @vue/composition-api vue-use-worker

# install with npm
npm install @vue/composition-api vue-use-worker

Usage

<template>
  <button @click="runReduce()">run reduce</button>
</template>

<script>
import useWorker from 'vue-use-worker';

export default {
  setup() {
    const reduce = array => array.reduce((acc, cur) => (acc * cur) / cur - Math.random(), 1);
    const [workerReduce] = useWorker(reduce);
    const numbers = [...Array(9000000)].map(() => Math.floor(Math.random() * 1000000));
    return { workerReduce, numbers };
  },
  methods: {
    async runReduce() {
      await this.workerReduce(this.numbers);
    }
  }
};
</script>

Author

👤 Tarek Touati

🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

Inspiration

This library is inspired by useWorker for React.


This README was generated with ❤️ by readme-md-generator