在Javascript ES6中,在浏览器中,我想使用"Transferable"界面将自定义类对象传输给Web worker.这可能吗?我可以找到有关ArrayBuffer对象的文档,但不能找到自定义类对象的文档.
这与如何通过Web-Workers传递自定义类实例不重复?因为我的问题是关于Transferable接口的.我想将自定义类实例传递给worker而不复制它.
这是一个简单的 SVG 蒙版(fiddle):
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="-100 -400 600 600">
<!-- Here I define the mask, a white rectangle with a strip removed -->
<defs>
<mask id="mymask">
<rect x="100" y="-200" width="200" height="100" fill="white"/>
<path d="M 250 -150 L 150 -150" stroke="black" fill="none" stroke-opacity="1" fill-opacity="1" stroke-width="25"/>
</mask>
</defs>
<!-- This masked blue rectangle is displayed correctly, and lets us see where the mask is -->
<rect x="-100" y="-300" width="500" height="500" fill="blue" fill-opacity="0.2" mask="url(#mymask)"/>
<!-- This green vertical line is …
Run Code Online (Sandbox Code Playgroud)