2016-01-21 09:58:28 -08:00
|
|
|
import {MessageBasedPlatformLocation} from './platform_location';
|
|
|
|
import {CONST_EXPR} from 'angular2/src/facade/lang';
|
refactor(Location): out of router and into platform/common
closes https://github.com/angular/angular/issues/4943
BREAKING CHANGE:
`Location` and other related providers have been moved out of `router` and into `platform/common`. `BrowserPlatformLocation` is not meant to be used directly however advanced configurations may use it via the following import change.
Before:
```
import {
PlatformLocation,
Location,
LocationStrategy,
HashLocationStrategy,
PathLocationStrategy,
APP_BASE_HREF}
from 'angular2/router';
import {BrowserPlatformLocation} from 'angular2/src/router/location/browser_platform_location';
```
After:
```
import {
PlatformLocation,
Location,
LocationStrategy,
HashLocationStrategy,
PathLocationStrategy,
APP_BASE_HREF}
from 'angular2/platform/common';
import {BrowserPlatformLocation} from 'angular2/src/platform/browser/location/browser_platform_location';
```
Closes #7962
2016-04-08 00:31:20 -07:00
|
|
|
import {
|
|
|
|
BrowserPlatformLocation
|
|
|
|
} from 'angular2/src/platform/browser/location/browser_platform_location';
|
2016-01-21 09:58:28 -08:00
|
|
|
import {APP_INITIALIZER, Provider, Injector, NgZone} from 'angular2/core';
|
|
|
|
|
|
|
|
export const WORKER_RENDER_ROUTER = CONST_EXPR([
|
2016-04-12 09:40:37 -07:00
|
|
|
MessageBasedPlatformLocation,
|
|
|
|
BrowserPlatformLocation,
|
|
|
|
CONST_EXPR(
|
|
|
|
new Provider(APP_INITIALIZER,
|
|
|
|
{useFactory: initRouterListeners, multi: true, deps: CONST_EXPR([Injector])}))
|
2016-01-21 09:58:28 -08:00
|
|
|
]);
|
|
|
|
|
|
|
|
function initRouterListeners(injector: Injector): () => void {
|
|
|
|
return () => {
|
|
|
|
let zone = injector.get(NgZone);
|
|
|
|
|
|
|
|
zone.run(() => injector.get(MessageBasedPlatformLocation).start());
|
|
|
|
};
|
|
|
|
}
|