israelss / vue-worker

A Vue.js plugin to use webworkers in a simply way.
MIT License
593 stars 41 forks source link

how to pass an external function to the worker? #20

Open Kaa10 opened 5 years ago

Kaa10 commented 5 years ago

Currently I would like to know if it is possible: Scenario, have two functions; The first is a generic function to create workers and returns value. The second is an external function that accesses through the mixin. My question is how do I pass this mixin function as a parameter for the worker's function to execute it?

4lp commented 4 years ago

Here's how I pass functions to vue-worker in a Vue component:

const myMethod = this.myMethod; this.$worker.run(myMethod(params));

hamelraj89 commented 4 years ago

Here's how pass functions to vue-worker in a Vue component:

const myMethod = this.myMethod; this.$worker.run(myMethod(params));

how this work as per your idea - https://github.com/israelss/vue-worker/issues/27

4lp commented 4 years ago

In your example in #27, try this.$worker.run(workerJob()); instead.

hamelraj89 commented 4 years ago

In your example in #27, try this.$worker.run(workerJob()); instead.

woerrjob is not defined error

4lp commented 4 years ago

Looks like maybe a typo based on your error message. If that's not it then I'm not sure what the issue could be : /

hamelraj89 commented 4 years ago

In your example in #27, try this.$worker.run(workerJob()); instead.

im getting below error ??

const workerJob= this.workerJob; this.$worker.run(workerJob());

TypeError: You should provide a function