Hi Jason, attempting to port my angular 2 app over to using web workers, but I am running into a similar exception:
"Error during instantiation of PlatformLocation! (AppComponent -> RouterService -> Router -> Location -> LocationStrategy -> PlatformLocation)" Is the Router not supported in web workers yet? Thanks On Tuesday, October 27, 2015 at 9:42:55 AM UTC-5, Dennis Smolek wrote: > > Jason, > > I'm just now starting to look into doing work with the web workers and > although the router doesnt work with components would it be possible to put > my services into a worker? > > On Monday, August 17, 2015 at 12:48:19 PM UTC-5, Jason Teplitz wrote: >> >> Hey Roland, >> >> Just wanted to give you an update on this. I talked to the router folks >> and getting the router to run in a WebWorker requires a bit more work than >> I initially anticipated. We've got the design sketched out though and >> should be able to implement it this week. >> >> On Monday, August 10, 2015 at 10:50:07 AM UTC-7, Jason Teplitz wrote: >>> >>> Unfortunately, it is necessary to do that right now because some of our >>> dependencies assume that those things are set on the window object. The >>> long term plan is to move that into the framework ( >>> https://github.com/angular/angular/issues/3207), but at the moment we >>> need to overwrite that object before loading any dependencies. >>> >>> On Monday, August 10, 2015 at 10:39:42 AM UTC-7, Roland Groza wrote: >>>> >>>> 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 https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
