Update to Angular 2 Beta 1. New bug: no longer waits for server-side HTTP requests to complete - waiting for info to resolve this.

This commit is contained in:
SteveSandersonMS
2016-01-25 15:13:30 +00:00
parent f44b84f2ab
commit 381b7b884e
32 changed files with 113 additions and 100 deletions

View File

@@ -13,7 +13,7 @@ builder.config({
},
meta: {
'angular2/*': { build: false },
'@reactivex/*': { build: false }
'rxjs/*': { build: false }
}
});

View File

@@ -15,7 +15,8 @@
"author": "Microsoft",
"license": "Apache-2.0",
"peerDependencies": {
"angular2": "2.0.0-alpha.44"
"angular2": "2.0.0-beta.1",
"rxjs": "5.0.0-beta.0"
},
"devDependencies": {
"systemjs-builder": "^0.14.11",

View File

@@ -1,5 +1,5 @@
import { provide, Injectable, Provider } from 'angular2/core';
import { Connection, ConnectionBackend, Http, XHRBackend, RequestOptions, Request, RequestMethods, Response, ResponseOptions, ReadyStates } from 'angular2/http';
import { Connection, ConnectionBackend, Http, XHRBackend, RequestOptions, Request, RequestMethod, Response, ResponseOptions, ReadyState } from 'angular2/http';
@Injectable()
export class CachePrimedConnectionBackend extends ConnectionBackend {
@@ -12,7 +12,7 @@ export class CachePrimedConnectionBackend extends ConnectionBackend {
public createConnection(request: Request): Connection {
let cacheKey = request.url;
if (request.method === RequestMethods.Get && this._preCachedResponses.hasOwnProperty(cacheKey)) {
if (request.method === RequestMethod.Get && this._preCachedResponses.hasOwnProperty(cacheKey)) {
return new CacheHitConnection(request, this._preCachedResponses[cacheKey], this._baseResponseOptions);
} else {
return this._underlyingBackend.createConnection(request);
@@ -21,21 +21,17 @@ export class CachePrimedConnectionBackend extends ConnectionBackend {
}
class CacheHitConnection implements Connection {
readyState: ReadyStates;
readyState: ReadyState;
request: Request;
response: any;
constructor (req: Request, cachedResponse: PreCachedResponse, baseResponseOptions: ResponseOptions) {
this.request = req;
this.readyState = ReadyStates.Done;
this.readyState = ReadyState.Done;
// Workaround for difficulty consuming CommonJS default exports in TypeScript. Note that it has to be a dynamic
// 'require', and not an 'import' statement, because the module isn't available on the server.
// All this badness goes away with the next update of Angular 2, as it exposes Observable directly from angular2/core.
// --
// The current version of Angular exposes the following SystemJS module directly (it is *not* coming from the
// @reactivex/rxjs NPM package - it's coming from angular2).
let obsCtor: any = require('@reactivex/rxjs/dist/cjs/Observable');
let obsCtor: any = require('rxjs/Observable').Observable;
this.response = new obsCtor(responseObserver => {
let response = new Response(new ResponseOptions({ body: cachedResponse.body, status: cachedResponse.statusCode }));
responseObserver.next(response);

View File

@@ -1,4 +1,4 @@
import { ControlGroup } from 'angular2/angular2';
import { ControlGroup } from 'angular2/common';
import { Response } from 'angular2/http';
export class Validation {