I figured that there was no support for Router yet, perhaps is because the
location object is available in web workers. Anyway, I'll try to remove the
routing and see how that works out as for now I only have one route anyway.
But I am a bit puzzled why is the window object overwritten:
window = {
setTimeout: setTimeout,
Map: Map,
Set: Set,
Array: Array,
Reflect: Reflect,
RegExp: RegExp,
Promise: Promise,
Date: Date,
zone: zone
};
assert = function() {};
According to MDN, a few of those object are actually exposed to a web
worker:
https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers
(right at the bottom of the page). Is it really necessary to do the above?
On Monday, August 10, 2015 at 7:25:52 PM UTC+2, Jason Teplitz wrote:
>
> Hey Roland,
>
> Glad to hear you're working on a WebWorker app! Just so you know,
> WebWorker support in angular is currently under heavy development and
> definitely not ready for prime time, but you're more than welcome to play
> around with it. I'd recommend using angular directly from source (npm
> install from our github repo: github.com/angular/angular) since we
> haven't got all the WebWorkers files bundled up properly for npm yet as you
> discovered with the zone-microtask file.
>
> Unfortunately, right now it looks like the Router isn't compatible with a
> WebWorker app. I've made an issue for this (
> https://github.com/angular/angular/issues/3563), and am going to try to
> look into it today. For now though, if you'd like to run your app in a
> WebWorker it looks like you can't use the router. I'll update this post if
> I discover any other workaround.
>
> Let me know if you have any more WebWorker questions!
>
> On Saturday, August 8, 2015 at 12:50:49 AM UTC-7, Roland Groza wrote:
>>
>> I've just tried to have this <https://github.com/rolandjitsu/ng2-play>
>> app running in a web worker by following the example
>> <https://github.com/angular/angular/tree/master/modules/examples/src/web_workers/kitchen_sink>
>>
>> on the angular repo, but I am not sure if I use the npm distribution and
>> I set up an app as the example, do I need the
>> zone-microtask-web-workers.js
>> <https://github.com/angular/angular/blob/master/modules/examples/src/assets/zone-microtask-web-workers.js>
>> that is used in the examples folder?
>>
>>
>> Because I am a bit confused about SCRIPTS.js
>> <https://github.com/angular/angular/blob/master/tools/broccoli/js-replace/SCRIPTS.js>
>> 's importScripts which does import the script I mentioned above and I
>> cannot seem to find it within the npm distribution.
>>
>>
>> After I manage to set it up though using the
>> zone-microtask-web-workers.js from the main repo, I did get an exception
>> from the Router:
>>
>>
>> EXCEPTION: Error during instantiation of LocationStrategy! (App -> Router
>> -> Location -> LocationStrategy).
>> ORIGINAL EXCEPTION: TypeError: Cannot read property 'getLocation' of
>> undefined
>> ORIGINAL STACKTRACE:
>> TypeError: Cannot read property 'getLocation' of undefined
>> at new HashLocationStrategy
>> (:8000/lib/angular2/src/router/hash_location_strategy.js:26)
>> at eval (reflection_capabilities.js:12)
>> at Injector._new (injector.js:555)
>> at InjectorDynamicStrategy.getObjByKeyId (injector.js:301)
>> at Injector._getByKeyDefault (injector.js:695)
>> at Injector._getByKey (injector.js:646)
>> at Injector._getByDependency (injector.js:632)
>> at Injector._new (injector.js:524)
>> at InjectorDynamicStrategy.getObjByKeyId (injector.js:301)
>> at Injector._getByKeyDefault (injector.js:695)
>>
>>
>>
>>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.