question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How can we use data and methods in vue-worker ?

See original GitHub issue

I have read this

It is not possible to pass as an arg this from a Vue Component. You can pass this.$data or any variable within data or computed

but no idea how to access data and methods insight worker ?

 export default {
        components: {
            Attribute,
            vueCustomScrollbar,
            Time
        },
        data() {
            return {
              user : {},
            }
        },
       computed:{
           reversedMessage: function () {
              return 100000;
            }
       },
       mounted() {
       // how to use vue worker to access 
           this.$worker.run(this.userDetails()); // not working
           this.$worker.run((arg1) => `this.$worker run 2: ${arg1}`, [this.$reversedMessage]). // not working
          this.$worker.run((arg1) => `this.$worker run 2: ${arg1}`, [this.$data.user]). // working
       },
        methods: {
          userDetails(){
          }
        }
}

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
vik17agcommented, Apr 17, 2021

You could do something in data like this -

data() { return { w: function () { return “this.$worker run 1: Function in other thread”; }, }; },

And then use in worker like this -

this.$worker .run(this.worker1()) .then(console.log) // logs ‘this.$worker run 1: Function in other thread’ .catch(console.error); // logs any possible error

0reactions
dyh333commented, Mar 1, 2022

@israelss would you please give some advice

Read more comments on GitHub >

github_iconTop Results From Across the Web

1. data and methods in Vuejs. Vue.js is a javascript ... - Medium
It's a function, which usually stores variables. methods: It's a type of function in the vue app, as we used to store every...
Read more >
Vue.js data() | How data() Works in vue.js with Examples
js data() method to the user. Basically in vue.js data() we defined collection of logic and stored in component using vue.js we can...
Read more >
What is Vue way to access to data from methods?
Inside methods if you don't have another scope defined inside, you can access your data like that: this.sendButtonDisable = true;.
Read more >
How to use web workers in Vue applications - Educative.io
Data is passed between the worker and the main thread via messages — the main thread and worker thread send messages using the...
Read more >
Use Web Workers with Ease in Vue.js with vue-worker
The core premise of vue-worker (or rather, simple-web-worker by the same author) is that Web Workers can be initialized from a Data URI,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found