{"id":200,"date":"2016-01-18T18:15:12","date_gmt":"2016-01-18T18:15:12","guid":{"rendered":"http:\/\/fluentreports.com\/blog\/?p=200"},"modified":"2016-01-18T18:22:39","modified_gmt":"2016-01-18T18:22:39","slug":"nativescript-and-webworkersthreads","status":"publish","type":"post","link":"http:\/\/fluentreports.com\/blog\/?p=200","title":{"rendered":"NativeScript and WebWorkers\/Threads"},"content":{"rendered":"<p><a href=\"http:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2016\/01\/gears-148196_960_720.png\" rel=\"attachment wp-att-202\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-medium wp-image-202\" src=\"http:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2016\/01\/gears-148196_960_720-273x300.png\" alt=\"gears-148196_960_720\" width=\"273\" height=\"300\" srcset=\"http:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2016\/01\/gears-148196_960_720-273x300.png 273w, http:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2016\/01\/gears-148196_960_720-624x686.png 624w, http:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2016\/01\/gears-148196_960_720.png 655w\" sizes=\"auto, (max-width: 273px) 100vw, 273px\" \/><\/a>So about 10 months ago, I put in an <a href=\"https:\/\/github.com\/NativeScript\/NativeScript\/issues\/85\">issue<\/a> for adding threads\/workers to NativeScript.\u00a0 I realized early on this was a major feature that is missing.\u00a0 10 months later, I still have that same opinion; the only real major feature NativeScript is really missing is background threads.\u00a0\u00a0 For a lot of projects this won't have an effect; but their are those that need to do processing and this missing feature is a major problem for these types of applications as there has not been a good way to work around it.<\/p>\n<p>Well mid-last week, a user x4080 posted a <a href=\"https:\/\/github.com\/NativeScript\/NativeScript\/issues\/1376\">question <\/a>about if WebViews main thread is tied to the NativeScript main thread or if it could be used as another thread.\u00a0 Light bulb went on in my head --\u00a0 awesome thinking outside the box by x4080!\u00a0\u00a0\u00a0\u00a0 I quickly created a test framework using an existing app I had written and tested it.\u00a0\u00a0 The threads are distinct!\u00a0\u00a0 Fast forward a couple days and today, I am happy to announce <a href=\"https:\/\/github.com\/NathanaelA\/nativescript-webworkers\">nativescript-webworkers<\/a>!\u00a0\u00a0 I have wrapped everything up on Android so that it works like a just like a traditional WebWorker with extras!\u00a0 iOS support should be later this week.<\/p>\n<p>To install you just need to do the standard <strong>nativescript plugin add nativescript-webworkers<\/strong> then you can follow my simple sample in the docs or any of the countless myriad of webworker examples on the web.\u00a0\u00a0 This does obviously increase the ram required and their is a startup cost for the webworker to be primed and ready to run.\u00a0\u00a0\u00a0 But if you have any processing you don't want on the main thread; we now have a solution that should solve most use cases where more than one thread is needed.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So about 10 months ago, I put in an issue for adding threads\/workers to NativeScript.\u00a0 I realized early on this was a major feature that is missing.\u00a0 10 months later, I still have that same opinion; the only real major feature NativeScript is really missing is background threads.\u00a0\u00a0 For a lot of projects this won't&hellip; <a class=\"more-link\" href=\"http:\/\/fluentreports.com\/blog\/?p=200\">Continue reading <span class=\"screen-reader-text\">NativeScript and WebWorkers\/Threads<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-200","post","type-post","status-publish","format-standard","hentry","category-uncategorized","entry"],"_links":{"self":[{"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/200","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=200"}],"version-history":[{"count":2,"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/200\/revisions"}],"predecessor-version":[{"id":203,"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/200\/revisions\/203"}],"wp:attachment":[{"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=200"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}