Git Product home page Git Product logo

vue-worker's Introduction

VueWorker

A Vue.js plugin to use webworkers in a simply way.

Changelog

1.2.1

Highlights:

  • Fix README examples

See full changelog here.

Why

Create and use Web Workers can be cumbersome sometimes. This plugin aims to facilitate the use of Web Workers within Vue components. It is a wrapper for simple-web-worker.

How to install and use

yarn add vue-worker

// or

npm install vue-worker --save

Then add in main.js:

import Vue from 'vue'
import VueWorker from 'vue-worker'
Vue.use(VueWorker)

That will inject a property into Vue (and pass it to every child component), with a default name of $worker, which can be accessed using this.$worker inside any Vue component.

You can change that name when registering the plugin:

import VueWorker from 'vue-worker'
Vue.use(VueWorker, '$desired-name')

API

NOTICE:

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, though.

this.$worker.run(func, [args]?)

Where:

  • func is the function to be runned in worker
  • [args] is an optional array of arguments that will be used by func

This method creates a disposable web worker, runs and returns the result of given function and closes the worker.



This method works like Promise.resolve(), but in another thread.

E.g.:

this.$worker.run(() => 'this.$worker run 1: Function in other thread')
  .then(console.log) // logs 'this.$worker run 1: Function in other thread'
  .catch(console.error) // logs any possible error

this.$worker.run((arg1, arg2) => `this.$worker run 2: ${arg1} ${arg2}`, ['Another', 'function in other thread'])
    .then(console.log) // logs 'this.$worker run 2: Another function in other thread'
    .catch(console.error) // logs any possible error

this.$worker.create([actions]?)

Where:

  • [actions] is an optional array of objects with two fields, message and func. Essentially, it is a messages-actions map.

If [actions] is omitted or undefined, the created <worker> will have no registered actions, so you'll have to use the method register before you can use the <worker>.



If you plan to reuse a ****, you should use this method. It creates a reusable **** (not a real Web Worker, more on this ahead) with determined actions to be runned through its `postMessage()` or `postAll()` methods.

E.g.:

const actions = [
  { message: 'func1', func: () => `Worker 1: Working on func1` },
  { message: 'func2', func: arg => `Worker 2: ${arg}` },
  { message: 'func3', func: arg => `Worker 3: ${arg}` },
  { message: 'func4', func: (arg = 'Working on func4') => `Worker 4: ${arg}` }
]

let worker = this.$worker.create(actions)

<worker>.postMessage(message, [args]?)

Where:

  • <worker> is a worker created with this.$worker.create([actions])
  • message is one of the messages in [actions]
  • [args] is an optional array of arguments that will be used by the function registered with message

When the function does not expect any arguments or the expected arguments have default values, [args] can be omitted safely.



When the expected arguments do not have default values, _[args]_ should be provided.

This method works like Promise.resolve(), but in another thread.

E.g.:

const actions = [
  { message: 'func1', func: () => `Worker 1: Working on func1` },
  { message: 'func2', func: arg => `Worker 2: ${arg}` },
  { message: 'func3', func: arg => `Worker 3: ${arg}` },
  { message: 'func4', func: (arg = 'Working on func4') => `Worker 4: ${arg}` }
]

let worker = this.$worker.create(actions)

worker.postMessage('func1')
  .then(console.log) // logs 'Worker 1: Working on func1'
  .catch(console.error) // logs any possible error

worker.postMessage('func1', ['Ignored', 'arguments'])
  .then(console.log) // logs 'Worker 1: Working on func1'
  .catch(console.error) // logs any possible error

worker.postMessage('func2')
  .then(console.log) // logs 'Worker 2: undefined'
  .catch(console.error) // logs any possible error

worker.postMessage('func3', ['Working on func3'])
  .then(console.log) // logs 'Worker 3: Working on func3'
  .catch(console.error) // logs any possible error

worker.postMessage('func4')
  .then(console.log) // logs 'Worker 4: Working on func4'
  .catch(console.error) // logs any possible error

worker.postMessage('func4', ['Overwrited argument'])
  .then(console.log) // logs 'Worker 4: Overwrited argument'
  .catch(console.error) // logs any possible error

<worker>.postAll([message1,... || {message: message1, args: [args1]},... || [args1],...]?)

Where:

  • <worker> is a worker created with this.$worker.create([actions])
  • The argument is an optional array which accepts one of the following:
    • message1,... - strings containing one or more of the messages in [actions]
    • {message: message1, args: [args1]},... - objects containing two fields, message (a message from actions) and args (the arguments to be used by the correspondent function)
    • [args1],... - arrays of arguments to be used by the registered actions.

If [message1,...] is undefined or no argument is given, <worker> will run all registered actions without arguments.



If _[{message: message1, args: [args1]},...]_ or _[[args1],...]_ is used, you should use `[]` (an empty array) as _[args]_ for the functions that does not expect arguments, or if the respective argument of your function has a default value and you want it to be used. If you use `[null]` this will be the value assumed by function argument.

When using _[[args1],...]_, you MUST input the same number of arguments as registered actions, even if some action doesn't accept any arguments! In that case use a `[]`, as stated above. See examples below.

If _[{message: message1, args: [args1]},...]_ is used, every object must contain the fields `message` and `args`.

This method works like Promise.all(), but in another thread.

E.g.:

const actions = [
  { message: 'func1', func: () => `Worker 1: Working on func1` },
  { message: 'func2', func: arg => `Worker 2: ${arg}` },
  { message: 'func3', func: arg => `Worker 3: ${arg}` },
  { message: 'func4', func: (arg = 'Working on func4') => `Worker 4: ${arg}` }
]

let worker = this.$worker.create(actions)

worker.postAll()
  .then(console.log) // logs ['Worker 1: Working on func1', 'Worker 2: undefined', 'Worker 3: undefined', 'Worker 4: Working on func4']
  .catch(console.error) // logs any possible error

worker.postAll(['func1', 'func3'])
  .then(console.log) // logs ['Worker 1: Working on func1', 'Worker 3: undefined']
  .catch(console.error) // logs any possible error

worker.postAll([{ message: 'func1', args: [] }, { message: 'func3', args: ['Working on func3'] })
  .then(console.log) // logs ['Worker 1: Working on func1', 'Worker 3: Working on func3']
  .catch(console.error) // logs any possible error

worker.postAll([[], ['Working on func2'], ['Working on func3'], []])
  .then(console.log) // logs ['Worker 1: Working on func1', 'Worker 2: Working on func2', 'Worker 3: Working on func3', 'Worker 4: Working on func4']
  .catch(console.error) // logs any possible error

worker.postAll([[], ['func2'], ['func3'], ['Overwriting default value of arg on func4']])
  .then(console.log) // logs ['Worker 1: Working on func1', 'Worker 2: func2', 'Worker 3: func3', 'Worker 4: Overwriting default value of arg on func4']
  .catch(console.error) // logs any possible error

<worker>.register(action || [actions])

Where:

  • <worker> is a worker created with this.$worker.create([actions])
  • action is an object with two fields, message and func
  • [actions] is an array of objects, and each object is an action, as defined above

You can use action or [actions], but not both at the same time.

E.g.:

const initialActions = [
  { message: 'func1', func: () => 'Working on func1' }
]

let worker = this.$worker.create(initialActions)

worker.postAll()
  .then(console.log) // logs ['Working on func1']
  .catch(console.error) // logs any possible error

// registering just one action
worker.register({ message: 'func2', func: () => 'Working on func2' })

worker.postAll()
  .then(console.log) // logs ['Working on func1', 'Working on func2']
  .catch(console.error) // logs any possible error

// registering multiple actions
worker.register([
  { message: 'func3', func: () => 'Working on func3' },
  { message: 'func4', func: () => 'Working on func4' }
])

worker.postAll()
  .then(console.log) // logs ['Working on func1', 'Working on func2', 'Working on func3', 'Working on func4']
  .catch(console.error) // logs any possible error

<worker>.unregister(message || [messages])

Where:

  • <worker> is a worker created with this.$worker.create([actions])
  • message is one of the messages in [actions]
  • [messages] is an array containing one or more messages, and each message is a message, as defined above

You can use message or [messages], but not both at the same time.

E.g.:

const initialActions = [
  { message: 'func1', func: () => 'Working on func1'},
  { message: 'func2', func: () => 'Working on func2'},
  { message: 'func3', func: () => 'Working on func3'},
  { message: 'func4', func: () => 'Working on func4'}
]

let worker = this.$worker.create(initialActions)

worker.postAll()
  .then(console.log) // logs ['Working on func1', 'Working on func2', 'Working on func3', 'Working on func4']
  .catch(console.error) // logs any possible error

// unregistering just one action
worker.unregister('func2')

worker.postAll()
  .then(console.log) // logs ['Working on func1', 'Working on func3', 'Working on func4']
  .catch(console.error) // logs any possible error

// unregistering multiple actions
worker.unregister(['func3', 'func1'])

worker.postAll()
  .then(console.log) // logs ['Working on func4']
  .catch(console.error) // logs any possible error

Closing workers?

You may be thinking: "How do I terminate those reusable workers if there's no close() or terminate() methods?"

Well, when you create a reusable worker, you don't receive a real Web Worker.

Instead, you get an object which holds the given messages-actions map, and when you call postMessage() or postAll() it will, under the hood, call run() with the correspondent functions.

So, to "terminate" a "worker" when it is not needed anymore, you can just do:

let worker = this.$worker.create(actions)

// use the worker

worker = null

vue-worker's People

Contributors

emilmoe avatar igordepaula avatar israelss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-worker's Issues

failed to run fetch in vue-worker

created() {
      this.$worker.run((arg) => {
        fetch("http://localhost:8080/dataPersistence/getApiList",{
          method:'GET',
          cache:"force-cache",
          headers:{
            "Content-Type": "application/json; charset=utf-8"
          }
        }).then(function(response) {
          response.json()
            .then(data => {
              console.log(data)              
            })
            .catch(error => {
              console.log('failed')
            })
        })
          .catch(function(myJson) {
            console.error('failed',myJson)
          })

        return `Hello, ${arg}!`
      }, ['World'])
    }

As you can see ,fetch is not run。。。
qq 20181227152000

Add the possibility to link a node to itself

Hi,

first thanks for the framework it really works great!

Do you think it would be possible to add links from a node to itself (i.e. a link with tid === sid)
so that it would be visible? As of now you can of course add that link but it isn't drawn

That would be really cool!

How to postMessage continuously?

hello,I'm a user of ur vue-worker,It's useful,but I encounter a problem

The scene:
I need a timerTask to post new Date to mainPage,So I write a demo as follow:
I write a timeout/interval in Fuction.run , but it's not take effect,could u give me a resolution?

preThx for help~

methods: {
startClock() {
    this.clock_worker = this.$worker
    .run(() =>{
       //var timer=()=>{
        //     setTimeout(timer,1000);
        // }
        // timer();     
        // setInterval(postMessage(new Date()),1000)
        //---------PS:  SETTIMEOUT && SETINTERVAL is not take effect
    })
    .then(res => console.log(res)) // logs 'this.$worker run 1: Function in other thread'
    .catch(console.error); // logs any possible error
}
},
mounted() {
if (typeof Worker === "undefined") {
  this.$message("您的浏览器不支持WebWorker,某些特性可能无法完美呈现");
} else {
  this.startClock();
}
}
 };

How delete the worker

Hi,

I have a problem to stop the worker before it finishes its task.
I tried to set worker = null in the destroyed method of the component but the execution continues.

How to do if for example we change page and stop the worker ?

Regards

How to send a message from vue-worker like worker.onmessage

I have that code:

    setInterval(() => {
      const options = { timeZone: "America/New_York"}, myTime = new Date();
      let est_time = myTime.toLocaleString("en-US", options)
      let now = new Date(est_time)

      let millisTill8 = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 8, 0, 0, 0) - now;
      if (millisTill8 < 0) {
        millisTill8 += 86400000; // try after 24 hours tomorrow
      }
      setTimeout(() => {
        this.is_live_chat_active = true
      }, millisTill8);

      let millisTill20 = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 20, 0, 0, 0) - now;
      if (millisTill20 < 0) {
        millisTill20 += 86400000; // try after 24 hours tomorrow
      }
      setTimeout(() => {
        this.is_live_chat_active = false
      }, millisTill20);
    }, 86400000);

I want to put it in vue worker. Every day, when the time is 8am or 8pm i want to toggle a boolean variable within a component.

Using just workers that would be possible by:

Worker.onmessage = (toggle) => {
  this.toggle_variable = toggle
}

But i can't figure out how to do this using vue-worker

Error in Laravel

I'm using Laravel, but I get an error when I try to import VueWorker

I only added the import VueWorker from 'vue-worker'; so that must be the error.

emil@debian:/var/www/dashboard$ gulp --production
[16:37:02] Using gulpfile /var/www/dashboard/gulpfile.js
[16:37:02] Starting 'all'...
[16:37:02] Starting 'sass'...
[16:37:04] Finished 'sass' after 2.4 s
[16:37:04] Starting 'webpack'...
{ Error
    at new JS_Parse_Error (eval at <anonymous> (/var/www/dashboard/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1534:18)
    at js_error (eval at <anonymous> (/var/www/dashboard/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1542:11)
    at croak (eval at <anonymous> (/var/www/dashboard/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2089:9)
    at token_error (eval at <anonymous> (/var/www/dashboard/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2097:9)
    at expect_token (eval at <anonymous> (/var/www/dashboard/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2110:9)
    at expect (eval at <anonymous> (/var/www/dashboard/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2113:36)
    at eval (eval at <anonymous> (/var/www/dashboard/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2686:13)
    at eval (eval at <anonymous> (/var/www/dashboard/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2136:24)
    at expr_atom (eval at <anonymous> (/var/www/dashboard/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2616:35)
    at maybe_unary (eval at <anonymous> (/var/www/dashboard/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2792:19)
  message: '/var/www/dashboard/app.js: SyntaxError: Unexpected token punc «(», expected punc «:»',
  fileName: '/var/www/dashboard/app.js',
  lineNumber: 42975,
  stack: 'Error\n    at new JS_Parse_Error (eval at <anonymous> (/var/www/dashboard/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1534:18)\n    at js_error (eval at <anonymous> (/var/www/dashboard/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1542:11)\n    at croak (eval at <anonymous> (/var/www/dashboard/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2089:9)\n    at token_error (eval at <anonymous> (/var/www/dashboard/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2097:9)\n    at expect_token (eval at <anonymous> (/var/www/dashboard/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2110:9)\n    at expect (eval at <anonymous> (/var/www/dashboard/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2113:36)\n    at eval (eval at <anonymous> (/var/www/dashboard/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2686:13)\n    at eval (eval at <anonymous> (/var/www/dashboard/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2136:24)\n    at expr_atom (eval at <anonymous> (/var/www/dashboard/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2616:35)\n    at maybe_unary (eval at <anonymous> (/var/www/dashboard/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2792:19)',
  showStack: false,
  showProperties: true,
  plugin: 'gulp-uglify' }

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

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(){
          }
        }
}

imported lodash functions not working in the worker function

When I run a function which uses imported lodash functions, I get an error:

Uncaught ReferenceError: __WEBPACK_IMPORTED_MODULE_10_lodash___default is not defined

Is there a workaround for this, or imported modules cannot be used in the function that are sent to the worker?

Synchronous example

Are you able to provide an example of how this can be used in a synchronous way at all using a setTimeout or something to then resolve the promise? And correctly destroying the instance.

Thanks

[Question] Context of `this`

As the title suggest what is the context of the this keyword inside the function this.$worker.run() i am i getting access to my data components?

Uncaught ReferenceError: xxx is not defined

// worker.js

const add = (a, b) => {
    return a + b
}

export const testfun = (a, b) => {
   return add(a, b)
}

import { testfun } from './worker.js';

const r = await this..$worker.run(testfun, [1,2]);

I get this:

Uncaught ReferenceError: add is not defined

Failed to execute 'postMessage' on 'Worker'

got this error, any ideas?

DOMException: Failed to execute 'postMessage' on 'Worker': function (){return ccall(ident,returnType,argTypes,arguments)} could not be cloned.
    at eval (webpack-internal:///622:1:3485)
    at new Promise (<anonymous>)
    at Worker.o.post (webpack-internal:///622:1:3301)
    at Object.run (webpack-internal:///622:1:3729)
    at eval (webpack-internal:///241:87:26)
    at http://code.dappbench.com/browser-solc.min.js:1:141533
    at HTMLScriptElement.d.readyState.d.onload (http://code.dappbench.com/browser-solc.min.js:1:141310)

vuex and vue-worker

Is it possible to access the vuex store from within a function passed onto a worker ?

Trying to install using npm but stuck with dependency

As per document I am trying to install using npm I received following error

c:\readinglog>npm install --save vue-worker
npm WARN [email protected] requires a peer of bufferutil@^4.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of utf-8-validate@^5.0.2 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename 'c:\readinglog\node_modules.staging\fsevents-4d267589\node_modules\readable-stream' -> 'c:\readinglog\node_modules.staging\readable-stream-5774a0a3'

npm ERR! path c:\readinglog\node_modules\simple-web-worker
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'c:\readinglog\node_modules\simple-web-worker' -> 'c:\readinglog\node_modules.simple-web-worker.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\nd185089\AppData\Roaming\npm-cache_logs\2020-07-27T13_13_02_273Z-debug.log

If I try to install other dependencies it goes on utill finally stuck with following error

c:\readinglog>npm install --save bufferutil utf-8-validate fsevents
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Valid OS: darwin
npm ERR! notsup Valid Arch: any
npm ERR! notsup Actual OS: win32
npm ERR! notsup Actual Arch: x64

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\nd185089\AppData\Roaming\npm-cache_logs\2020-07-27T13_20_27_964Z-debug.log

setInterval dosen't work

This is my code:

methods: {
   setTimer(val) {
      this.timerWorker = this.$worker.run(function(val) {
        console.log(setInterval)
        console.log(val)
        const timer = setInterval(function() {
          val -= 17
          console.log('setInterval', val)
        }, 17);
        return val
      }, [val]).then(res => {
        console.log(res)
      })
    }
}

And then, 'setInterval' didn't show up.

How to use methods in worker ?

i have methods like this

methods: {
    workerJob(){
        var count = 0;
        for (var i = 0; i < 5; i++) {
            count ++;
        }
   }
}

How can i call workerJob() using vue-worker ? below code is giving error Uncaught ReferenceError: _this is not defined

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

how to use vue-worker in Axios

for example,request callback

getCoreIndicatorList(params).then(({ data }) => {
       this.$worker.run((context,source)=>{
          context.coreIndicator= source.todayTotalAmount | 0
      },[this,data]).
       .then(() => // do something})
       .catch(console.error)

Failed to execute 'postMessage' on 'Worker': function () { [native code] } could not be cloned.

how to pass an external function to the worker?

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?

Error when importing into a electron-vue app

Hi,

I'm trying to use VueWorker in an app created with electron-vue, [https://github.com/SimulatedGREG/electron-vue].

When importing VueWorker, I get the following error,
Uncaught SyntaxError: Unexpected token import at createScript (vm.js:74) at Object.runInThisContext (vm.js:116) at Module._compile (module.js:533) at Object.Module._extensions..js (module.js:580) at Module.load (module.js:503) at tryModuleLoad (module.js:466) at Function.Module._load (module.js:458) at Module.require (module.js:513) at require (internal/module.js:11) at eval (external "vue-worker"?b6d5:1)

I don't know if this is a problem with electron-vue or with VueWorker, thought I'll ask here first.
The error is reported in \node_modules\vue-worker\index.js:1.

Steps:

Create an empty project with vue init simulatedgreg/electron-vue my-project

Then npm install vue-worker and import it in the main.js created by electron-vue.

As soon as you start the application, you'll see the error.

Any ideas ?

Thanks.

I posted an issue on electron-vue as well, SimulatedGREG/electron-vue/issues/562

Uncaught ReferenceError: _ref2 is not defined

submitFlag() {
      const { flag, token } = this.$data;
      const info = this.info;
      const local = { owner: "user", repository: "repo" };
      const upstream = {
        owner: config.owner,
        repository: config.submissionsRepo
      };

      this.$worker
        .run(
          async (flag, info, token, local, upstream) => {
            const NIZKCTF = require("../services/nizkctf");
            const nizkctf = new NIZKCTF(token, local, upstream);

            return await nizkctf.submitFlag(flag, info);
          },
          [flag, info, token, local, upstream]
        )
        .then(r => console.log(r))
        .catch(r => console.log("Error", r));
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.