How to pass functions to JavaScript Web Worker

后端 未结 3 1522
抹茶落季
抹茶落季 2021-02-02 09:35

I would like to pass a function (or functions) via a postMessage() to a web worker, because I can\'t refer to regular files.

To kick the web worker off, I a

3条回答
  •  野性不改
    2021-02-02 10:21

    Turns out this method works fine, there was merely a bug in my worker:

    var result = greeter("john");
    

    should be

    var result = greet("john");
    

    which makes sense - I'm passing the greeter variable to the worker, but there's no reason for it to know the variable name of the object I'm passing.

提交回复
热议问题