2015-09-03 22:01:36 -07:00
|
|
|
import {Injectable} from 'angular2/src/core/di';
|
2015-08-21 16:55:50 -07:00
|
|
|
import {PRIMITIVE} from 'angular2/src/web_workers/shared/serializer';
|
2015-08-21 12:21:29 -07:00
|
|
|
import {XHR_CHANNEL} from 'angular2/src/web_workers/shared/messaging_api';
|
2015-11-05 14:07:57 -08:00
|
|
|
import {XHR} from 'angular2/src/compiler/xhr';
|
2015-08-21 16:55:50 -07:00
|
|
|
import {ServiceMessageBrokerFactory} from 'angular2/src/web_workers/shared/service_message_broker';
|
|
|
|
import {bind} from './bind';
|
2015-08-17 10:28:47 -07:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class MessageBasedXHRImpl {
|
2015-09-01 10:55:11 -07:00
|
|
|
constructor(private _brokerFactory: ServiceMessageBrokerFactory, private _xhr: XHR) {}
|
|
|
|
|
|
|
|
start(): void {
|
|
|
|
var broker = this._brokerFactory.createMessageBroker(XHR_CHANNEL);
|
2015-08-21 16:55:50 -07:00
|
|
|
broker.registerMethod("get", [PRIMITIVE], bind(this._xhr.get, this._xhr), PRIMITIVE);
|
2015-08-17 10:28:47 -07:00
|
|
|
}
|
|
|
|
}
|