refactor(async): use ultralight Observable

Closes #5283
This commit is contained in:
Rob Wormald 2015-11-14 00:02:57 -08:00 committed by Jeremy Elbourn
parent ad99199d50
commit a16ac84840
10 changed files with 83 additions and 53 deletions

View File

@ -3,9 +3,13 @@ import {global, isPresent, noop} from 'angular2/src/facade/lang';
// without depending on rxjs.
import {PromiseWrapper, Promise, PromiseCompleter} from 'angular2/src/facade/promise';
export {PromiseWrapper, Promise, PromiseCompleter} from 'angular2/src/facade/promise';
import {Subject, Subscription, Observable as RxObservable} from '@reactivex/rxjs/dist/cjs/Rx';
export {Subject} from '@reactivex/rxjs/dist/cjs/Rx';
import Operator from '@reactivex/rxjs/dist/cjs/Operator';
import {Subject} from '@reactivex/rxjs/dist/cjs/Subject';
import {Observable as RxObservable} from '@reactivex/rxjs/dist/cjs/Observable';
import {Subscription} from '@reactivex/rxjs/dist/cjs/Subscription';
import {Operator} from '@reactivex/rxjs/dist/cjs/Operator';
export {Subject} from '@reactivex/rxjs/dist/cjs/Subject';
export namespace NodeJS {
export interface Timer {}

View File

@ -0,0 +1,5 @@
library angular2.test.facade.observable_spec;
main() {
//stub to ignore JS Observable specific tests
}

View File

@ -0,0 +1,63 @@
import {
describe,
it,
expect,
beforeEach,
ddescribe,
iit,
xit,
el,
SpyObject,
AsyncTestCompleter,
inject
} from 'angular2/testing_internal';
import {Observable, Subject, EventEmitter, PromiseWrapper} from 'angular2/src/facade/async';
export function main() {
describe("Observable", () => {
describe("#core", () => {
it("should call next with values", inject([AsyncTestCompleter], (async) => {
let o = new Observable(sink => { sink.next(1); });
o.subscribe(v => {
expect(v).toEqual(1);
async.done();
});
}));
it("should call next and then complete", inject([AsyncTestCompleter], (async) => {
let o = new Observable(sink => {
sink.next(1);
sink.complete();
});
let nexted = false;
o.subscribe(v => { nexted = true; }, null, () => {
expect(nexted).toBe(true);
async.done();
});
}));
it("should call error with errors", inject([AsyncTestCompleter], (async) => {
let o = new Observable(sink => { sink.error('oh noes!'); });
o.subscribe(
v => {
},
(err) => {
expect(err).toEqual('oh noes!');
async.done();
});
}));
});
});
}

View File

@ -686,51 +686,9 @@ var NG_ALL = [
/*
RxJS API - may need to maintain as RxJS evolves
*/
'EventEmitter.mapTo():js',
'EventEmitter.next():js',
'EventEmitter.emit():js',
'EventEmitter.materialize():js',
'EventEmitter.merge():js',
'EventEmitter.mergeAll():js',
'EventEmitter.mergeMap():js',
'EventEmitter.mergeMapTo():js',
'EventEmitter.multicast():js',
'EventEmitter.observeOn():js',
'EventEmitter.remove():js',
'EventEmitter.repeat():js',
'EventEmitter.retry():js',
'EventEmitter.retryWhen():js',
'EventEmitter.throttle():js',
'EventEmitter.toPromise():js',
'EventEmitter.window():js',
'EventEmitter.windowCount():js',
'EventEmitter.windowTime():js',
'EventEmitter.windowToggle():js',
'EventEmitter.windowWhen():js',
'EventEmitter.withLatestFrom():js',
'EventEmitter.zip():js',
'EventEmitter.zipAll():js',
'Observable:js',
'Observable#combineLatest():js',
'Observable#concat():js',
'Observable#create():js',
'Observable#defer():js',
'Observable#empty():js',
'Observable#forkJoin():js',
'Observable#from():js',
'Observable#fromArray():js',
'Observable#fromEvent():js',
'Observable#fromEventPattern():js',
'Observable#fromPromise():js',
'Observable#interval():js',
'Observable#merge():js',
'Observable#never():js',
'Observable#of():js',
'Observable#range():js',
'Observable#throw():js',
'Observable#timer():js',
'Observable#zip():js',
'Observable.buffer():js',
'Observable.bufferCount():js',
'Observable.bufferTime():js',

View File

@ -16,8 +16,6 @@ import {Http, Response} from 'angular2/http';
export class HttpCmp {
people: Object[];
constructor(http: Http) {
http.get('./people.json')
.map((res: Response) => res.json())
.subscribe((people: Array<Object>) => this.people = people);
http.get('./people.json').subscribe(res => { this.people = res.json(); });
}
}

View File

@ -1,7 +1,7 @@
{
"dependencies": {
"@reactivex/rxjs": {
"version": "5.0.0-alpha.7"
"version": "5.0.0-alpha.10"
},
"angular": {
"version": "1.4.7"

6
npm-shrinkwrap.json generated
View File

@ -3,9 +3,9 @@
"version": "2.0.0-alpha.46",
"dependencies": {
"@reactivex/rxjs": {
"version": "5.0.0-alpha.7",
"from": "https://registry.npmjs.org/@reactivex/rxjs/-/rxjs-5.0.0-alpha.7.tgz",
"resolved": "https://registry.npmjs.org/@reactivex/rxjs/-/rxjs-5.0.0-alpha.7.tgz"
"version": "5.0.0-alpha.10",
"from": "@reactivex/rxjs@5.0.0-alpha.10",
"resolved": "http://registry.npmjs.org/@reactivex/rxjs/-/rxjs-5.0.0-alpha.10.tgz"
},
"angular": {
"version": "1.4.7",

View File

@ -31,7 +31,7 @@
"test": "gulp test.all.js && gulp test.all.dart"
},
"dependencies": {
"@reactivex/rxjs": "5.0.0-alpha.7",
"@reactivex/rxjs": "5.0.0-alpha.10",
"reflect-metadata": "0.1.2",
"zone.js": "0.5.8"
},

View File

@ -12,6 +12,7 @@
'angular2/src/testing/benchmark_util': {defaultExtension: 'js'},
'angular2/src/facade/browser': {defaultExtension: 'js'},
'angular2/bootstrap': {defaultExtension: 'js'},
'rxjs': {defaultExtension: 'js'},
}
});
</script>

View File

@ -13,6 +13,7 @@
'angular2/src/testing/benchmark_util': {defaultExtension: 'js'},
'angular2/src/facade/browser': {defaultExtension: 'js'},
'angular2/bootstrap': {defaultExtension: 'js'},
'rxjs': {defaultExtension: 'js'},
}
});
</script>