mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
79472b77ca
This is part of ongoing work to make core platform-independent.
BREAKING CHANGE
All private exports from 'angular2/src/core/facade/{lang,collection,exception_handler}' should be replaced with 'angular2/src/facade/{lang,collection,exception_handler}'.
28 lines
988 B
TypeScript
28 lines
988 B
TypeScript
import {SETUP_CHANNEL} from 'angular2/src/web_workers/shared/messaging_api';
|
|
import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
|
|
import {MessageBus} from 'angular2/src/web_workers/shared/message_bus';
|
|
import {AnchorBasedAppRootUrl} from 'angular2/src/compiler/anchor_based_app_root_url';
|
|
import {StringWrapper} from 'angular2/src/facade/lang';
|
|
import {Injectable} from 'angular2/src/core/di';
|
|
|
|
@Injectable()
|
|
export class WebWorkerSetup {
|
|
rootUrl: string;
|
|
|
|
constructor(private _bus: MessageBus, anchorBasedAppRootUrl: AnchorBasedAppRootUrl) {
|
|
this.rootUrl = anchorBasedAppRootUrl.value;
|
|
}
|
|
|
|
start(): void {
|
|
this._bus.initChannel(SETUP_CHANNEL, false);
|
|
var sink = this._bus.to(SETUP_CHANNEL);
|
|
var source = this._bus.from(SETUP_CHANNEL);
|
|
|
|
ObservableWrapper.subscribe(source, (message: string) => {
|
|
if (StringWrapper.equals(message, "ready")) {
|
|
ObservableWrapper.callNext(sink, {"rootUrl": this.rootUrl});
|
|
}
|
|
});
|
|
}
|
|
}
|