How to pass functions to JavaScript Web Worker

后端 未结 3 1518
抹茶落季
抹茶落季 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:16

    For those who are looking for more generic answer: here is a plugin, which allows you to execute any function of your javascript code in a thread.

    http://www.eslinstructor.net/vkthread/

    Consider it as "function outsourcing". You pass any function to the plugin as an argument and get result in callback. You also can "outsource" object's methods, function with dependecies, anonymous function and lambda.

    Enjoy.

    --Vadim

提交回复
热议问题