nativescript-webworkers
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "nativescript-webworkers", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A WebWorker (thread) NativeScript module for Android and iOS (soon)", | ||
@@ -8,3 +8,3 @@ "main": "webworkers.js", | ||
"platforms": { | ||
"android": "0.0.1", | ||
"android": "0.0.2", | ||
"ios": "0.0.0" | ||
@@ -11,0 +11,0 @@ } |
@@ -10,3 +10,3 @@ # nativescript-webworkers | ||
This is the first version; it only supports andoid at the moment; but iOS should be supportable. | ||
This is the first version; it only supports andoid at the moment; but iOS should be supportable soon. | ||
@@ -42,3 +42,4 @@ Please note The WebWorker environment is a LIMITED JavaScript shell. It does have AJAX/HTTP(s) ability; but it does NOT have any access to any of the NativeScript api. It also does not have any access to the Native iOS or Android api's. It is strictly a JS thread. In addition at this moment "ImportScripts" has not been implemented. It should be fairly easy to implement; and if anyone wants to do a pull request to implement this; I'd be happy to add it to the code that gets injected into the environment. | ||
####.onready | ||
This is NOT a normal webworker event, and you do not have to use it; but it is fired when the webworker environment is ready to go. | ||
This is fired when the webworker environment is ready to go. | ||
**This is NOT a standard webworker function** | ||
@@ -58,2 +59,6 @@ ### Methods | ||
####onready() | ||
This function will get called if it exists once the webworker is able to communicate with the NativeScript host. | ||
**This is NOT a standard webworker function** | ||
### Methods | ||
@@ -79,5 +84,7 @@ ####postMessage(data) | ||
onmessage = function(m) { | ||
console.log("NativeScript said" + m); | ||
postMessage("Hi"); | ||
console.log("NativeScript said" + m); | ||
}; | ||
onready = function() { | ||
postMessage("Hi"); | ||
}; | ||
``` |
@@ -8,3 +8,3 @@ /********************************************************************************** | ||
* Any questions please feel free to email me or put a issue up on the github repo | ||
* Version 0.0.1 Nathan@master-technology.com | ||
* Version 0.0.2 Nathan@master-technology.com | ||
*********************************************************************************/ | ||
@@ -111,5 +111,8 @@ "use strict"; | ||
this._initialized = true; | ||
// TODO: Add "ImportScripts(script[, script...]) | ||
var script = "window.postMessage = function(data) { try { confirm(JSON.stringify(data)); } catch (e) { console.error(e); } }; " + | ||
"window._WW_receiveMessage = function(d) { try { window.onmessage(d); } catch (e) { console.error(e); postMessage({_BRM: 'error', error: e}); } }; " + | ||
"window.close = function() { postMessage({_BRM: 'close'}); }; "; | ||
"window._WW_receiveMessage = function(d) { setTimeout(function() { _WW_timedMessage(d); },0); }; " + | ||
"window._WW_timedMessage = function(d) { try { window.onmessage(d); } catch (e) { console.error(e); postMessage({_BRM: 'error', error: e}); } }; " + | ||
"window.close = function() { postMessage({_BRM: 'close'}); }; " + | ||
"if (typeof onready === 'function') { onready(); } "; | ||
@@ -116,0 +119,0 @@ //noinspection JSUnresolvedFunction |
12234
174
87