{"id":140,"date":"2019-07-24T07:07:12","date_gmt":"2019-07-24T06:07:12","guid":{"rendered":"http:\/\/blog.c-hase.de\/?p=140"},"modified":"2019-07-24T08:05:42","modified_gmt":"2019-07-24T07:05:42","slug":"web-workers-mit-parametern","status":"publish","type":"post","link":"http:\/\/blog.c-hase.de\/?p=140","title":{"rendered":"web workers mit parametern"},"content":{"rendered":"<div class=\"votecell post-layout--left\">\n<div class=\"js-voting-container grid fd-column ai-stretch gs4 fc-black-200\" data-post-id=\"4019297\">\n<div class=\"js-accepted-answer-indicator grid--item fc-green-500 ta-center p4\" tabindex=\"0\" title=\"loading when this answer was accepted...\" role=\"note\" aria-label=\"accepted\"><a href=\"https:\/\/www.developer.com\/lang\/jscript\/7-things-you-need-to-know-about-web-workers.html\">https:\/\/www.developer.com\/lang\/jscript\/7-things-you-need-to-know-about-web-workers.html<\/a><\/div>\n<\/div>\n<\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"post-text\">\n<p>As you can see you have the same mechanism for both worker-to-main and main-to-worker messages.<\/p>\n<ul>\n<li>the <code>postMessage<\/code> method for sending messages<\/li>\n<li>the <code>onmessage<\/code> member for defining the handler that receives the messages<\/li>\n<\/ul>\n<p>In the main script:<\/p>\n<pre><code>worker.postMessage(data);\r\n<\/code><\/pre>\n<p>In the worker script:<\/p>\n<pre><code>self.addEventListener(\"message\", function(e) {\r\n    \/\/ the passed-in data is available via e.data\r\n}, false);\r\n<\/code><\/pre>\n<p>&#8230; or just&#8230;<\/p>\n<pre><code>onmessage = function(e) {\r\n    \/\/ the passed-in data is available via e.data\r\n};\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/www.developer.com\/lang\/jscript\/7-things-you-need-to-know-about-web-workers.html As you can see you have the same mechanism for both worker-to-main and main-to-worker messages. the postMessage method for sending messages the onmessage member for defining the handler that receives the messages In the main script: worker.postMessage(data); In the &hellip; <a href=\"http:\/\/blog.c-hase.de\/?p=140\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-140","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/blog.c-hase.de\/index.php?rest_route=\/wp\/v2\/posts\/140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.c-hase.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.c-hase.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.c-hase.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.c-hase.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=140"}],"version-history":[{"count":3,"href":"http:\/\/blog.c-hase.de\/index.php?rest_route=\/wp\/v2\/posts\/140\/revisions"}],"predecessor-version":[{"id":143,"href":"http:\/\/blog.c-hase.de\/index.php?rest_route=\/wp\/v2\/posts\/140\/revisions\/143"}],"wp:attachment":[{"href":"http:\/\/blog.c-hase.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.c-hase.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=140"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.c-hase.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}