refactor(async): replace RxJS with RxNext

Closes #3110
Closes #4201
This commit is contained in:
vsavkin 2015-09-11 15:38:09 -07:00 committed by Jeff Cross
parent 7b3161a229
commit 16bf335a4a
25 changed files with 61 additions and 96 deletions

View File

@ -50,7 +50,7 @@ module.exports = new Package('angular-v2-docs', [jsdocPackage, nunjucksPackage,
createTypeDefinitionFile.typeDefinitions = [
{
id: 'angular2/angular2',
references: ['../es6-promise/es6-promise.d.ts', '../rx/rx.d.ts'],
references: ['../es6-promise/es6-promise.d.ts'],
modules: {
'angular2/angular2': {namespace: 'ng', id: 'angular2/angular2'},
'angular2/web_worker/worker': {namespace: 'ngWorker', id: 'angular2/web_worker/worker'},

View File

@ -359,8 +359,8 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
function getType(sourceFile, type) {
var text = getText(sourceFile, type);
while (text.indexOf(".") >= 0) {
// Keep namespaced symbols in Rx
if (text.match(/^\s*Rx\./)) break;
// Keep namespaced symbols in RxNext
if (text.match(/^\s*RxNext\./)) break;
// handle the case List<thing.stuff> -> List<stuff>
text = text.replace(/([^.<]*)\.([^>]*)/, "$2");
}

View File

@ -1017,11 +1017,13 @@ gulp.task('!build.js.cjs', function() {
var bundleConfig = {
paths: {"*": "dist/js/prod/es5/*.js", "rx": "node_modules/rx/dist/rx.js"},
paths: {
"*": "dist/js/prod/es5/*.js"
},
meta: {
'angular2/src/router/route_definition': {format: 'cjs'},
// auto-detection fails to detect properly here - https://github.com/systemjs/builder/issues/123
'rx': {format: 'cjs'}
'angular2/src/router/route_definition': {
format: 'cjs'
}
}
};
@ -1072,7 +1074,10 @@ gulp.task('!bundle.js.min', ['build.js.prod'], function() {
// development build
gulp.task('!bundle.js.dev', ['build.js.dev'], function() {
var devBundleConfig = merge(true, bundleConfig);
devBundleConfig.paths = merge(true, devBundleConfig.paths, {"*": "dist/js/dev/es5/*.js"});
devBundleConfig.paths =
merge(true, devBundleConfig.paths, {
"*": "dist/js/dev/es5/*.js"
});
return bundler.bundle(
devBundleConfig,
'angular2/angular2',
@ -1150,7 +1155,7 @@ gulp.task('!bundle.js.prod.deps', ['!bundle.js.prod'], function() {
'angular2.js'
),
bundler.modify(
['node_modules/reflect-metadata/Reflect.js', 'node_modules/rx/dist/rx.lite.js', 'dist/build/http.js'],
['node_modules/reflect-metadata/Reflect.js', 'dist/build/http.js'],
'http.js'
)).pipe(gulp.dest('dist/js/bundle'));
});
@ -1162,7 +1167,7 @@ gulp.task('!bundle.js.min.deps', ['!bundle.js.min'], function() {
'angular2.min.js'
),
bundler.modify(
['node_modules/reflect-metadata/Reflect.js', 'node_modules/rx/dist/rx.lite.js','dist/build/http.min.js'],
['node_modules/reflect-metadata/Reflect.js', 'dist/build/http.min.js'],
'http.min.js'
))
.pipe(uglify())
@ -1179,9 +1184,9 @@ var JS_DEV_DEPS = [
// Splice in RX license if rx is in the bundle.
function insertRXLicense(source) {
var n = source.indexOf('System.register("rx"');
var n = source.indexOf('System.register("@reactivex/rxjs/dist/cjs/Subject"');
if (n >= 0) {
var rxLicense = licenseWrap('node_modules/rx/license.txt');
var rxLicense = licenseWrap('node_modules/@reactivex/rxjs/LICENSE.txt');
return source.slice(0, n) + rxLicense + source.slice(n);
} else {
return source;

View File

@ -21,7 +21,7 @@ module.exports = function(config) {
// Including systemjs because it defines `__eval`, which produces correct stack traces.
'modules/angular2/src/test_lib/shims_for_IE.js',
'node_modules/systemjs/dist/system.src.js',
{pattern: 'node_modules/rx/dist/rx.js', included: false, watched: false, served: true},
{pattern: 'node_modules/@reactivex/rxjs/dist/cjs/**', included: false, watched: false, served: true},
'node_modules/reflect-metadata/Reflect.js',
'tools/build/file2modulename.js',
'test-main.js',

View File

@ -10,7 +10,7 @@
"dependencies": {
"traceur": "<%= packageJson.dependencies.traceur %>",
"reflect-metadata": "<%= packageJson.dependencies['reflect-metadata'] %>",
"rx": "<%= packageJson.dependencies['rx'] %>",
"@reactivex/rxjs": "<%= packageJson.dependencies['@reactivex/rxjs'] %>",
"zone.js": "<%= packageJson.dependencies['zone.js'] %>"
},
"devDependencies": <%= JSON.stringify(packageJson.defaultDevDependencies) %>,

View File

@ -1,6 +1,7 @@
///<reference path="../../../typings/tsd.d.ts" />
import {global, isPresent} from 'angular2/src/core/facade/lang';
import * as Rx from 'rx';
// TODO(jeffbcross): use ES6 import once typings are available
var Subject = require('@reactivex/rxjs/dist/cjs/Subject');
export {Promise};
@ -75,7 +76,7 @@ export class ObservableWrapper {
static isObservable(obs: any): boolean { return obs instanceof Observable; }
static dispose(subscription: any) { subscription.dispose(); }
static dispose(subscription: any) { subscription.unsubscribe(); }
static callNext(emitter: EventEmitter, value: any) { emitter.next(value); }
@ -128,30 +129,19 @@ export class Observable {
* Once a reference implementation of the spec is available, switch to it.
*/
export class EventEmitter extends Observable {
_subject: Rx.Subject<any> = new Rx.Subject<any>();
_immediateScheduler = (<any>Rx.Scheduler).immediate;
_subject = new Subject();
observer(generator: any): Rx.IDisposable {
return this._subject.observeOn(this._immediateScheduler)
.subscribe((value) => { setTimeout(() => generator.next(value)); },
observer(generator: any): any {
return this._subject.subscribe((value) => { setTimeout(() => generator.next(value)); },
(error) => generator.throw ? generator.throw(error) : null,
() => generator.return ? generator.return () : null);
}
toRx(): Rx.Observable<any> { return this._subject; }
toRx(): any { return this; }
/**
* Emits a `value`.
*/
next(value: any) { this._subject.onNext(value); }
next(value: any) { this._subject.next(value); }
/**
* Emits an `error`.
*/
throw(error: any) { this._subject.onError(error); }
throw(error: any) { this._subject.error(error); }
/**
* Closes the stream.
*/
return (value?: any) { this._subject.onCompleted(); }
return (value?: any) { this._subject.complete(); }
}

View File

@ -1,5 +1,3 @@
/// <reference path="../../typings/rx/rx.d.ts" />
import {
ReadyStates,
RequestModesOpts,

View File

@ -9,7 +9,7 @@
"repository": <%= JSON.stringify(packageJson.repository) %>,
"dependencies": {
"angular2": "<%= packageJson.version %>",
"rx": "<%= packageJson.dependencies['rx'] %>",
"@reactivex/rxjs": "<%= packageJson.dependencies['@reactivex/rxjs'] %>",
"reflect-metadata": "<%= packageJson.dependencies['reflect-metadata'] %>",
"traceur": "<%= packageJson.dependencies['traceur'] %>"
},

View File

@ -1,5 +1,4 @@
import {EventEmitter} from 'angular2/src/core/facade/async';
import * as Rx from 'rx';
import {ListWrapper} from 'angular2/src/core/facade/collection';
export class MockEventEmitter extends EventEmitter {
@ -7,7 +6,7 @@ export class MockEventEmitter extends EventEmitter {
constructor() { super(); }
observer(generator: any): Rx.IDisposable {
observer(generator: any): any {
this._nextFns.push(generator.next);
return new MockDisposable();
}
@ -17,6 +16,7 @@ export class MockEventEmitter extends EventEmitter {
}
}
class MockDisposable implements Rx.IDisposable {
dispose(): void {}
class MockDisposable {
isUnsubscribed: boolean = false;
unsubscribe(): void {}
}

View File

@ -17,14 +17,6 @@
"node/node.d.ts": {
"commit": "51738fdf1643d269067861b405e87503b7479236"
},
"rx/rx.d.ts": {
"commit": "3882d337bb0808cde9fe4c08012508a48c135482"
},
"rx/rx-lite.d.ts": {
"commit": "3882d337bb0808cde9fe4c08012508a48c135482"
},
"selenium-webdriver/selenium-webdriver.d.ts": {
"commit": "be0b6b394f77a59e192ad7cfec18078706e44db5"

View File

@ -10,7 +10,7 @@
"dependencies": {
"angular2": "<%= packageJson.version %>",
"traceur": "<%= packageJson.dependencies.traceur %>",
"rx": "<%= packageJson.dependencies['rx'] %>",
"@reactivex/rxjs": "<%= packageJson.dependencies['@reactivex/rxjs'] %>",
"zone.js": "<%= packageJson.dependencies['zone.js'] %>"
},
"devDependencies": <%= JSON.stringify(packageJson.defaultDevDependencies) %>

View File

@ -1,5 +1,3 @@
/// <reference path="../../../angular2/typings/rx/rx.d.ts" />
import {bootstrap} from 'angular2/bootstrap';
import {HTTP_BINDINGS} from 'angular2/http';
import {HttpCmp} from './http_comp';

View File

@ -1,5 +1,3 @@
/// <reference path="../../../angular2/typings/rx/rx.d.ts" />
import {bootstrap} from 'angular2/bootstrap';
import {JSONP_BINDINGS} from 'angular2/http';
import {JsonpCmp} from './jsonp_comp';

View File

@ -4,10 +4,7 @@ importScripts("b64.js");
System.config({
baseURL: '/',
defaultJSExtensions: true,
paths: {
'rx': 'examples/src/web_workers/images/rx.js'
}
defaultJSExtensions: true
});
System.import("examples/src/web_workers/images/background_index")

View File

@ -2,10 +2,7 @@ $SCRIPTS$
System.config({
baseURL: '/',
defaultJSExtensions: true,
paths: {
'rx': 'examples/src/web_workers/kitchen_sink/rx.js'
}
defaultJSExtensions: true
});
System.import("examples/src/web_workers/kitchen_sink/background_index")

View File

@ -2,8 +2,7 @@ $SCRIPTS$
System.config({
baseURL: '/',
defaultJSExtensions: true,
paths: {'rx': 'examples/src/web_workers/message_broker/rx.js'}
defaultJSExtensions: true
});
System.import("examples/src/web_workers/message_broker/background_index")

View File

@ -2,10 +2,7 @@ $SCRIPTS$
System.config({
baseURL: '/',
defaultJSExtensions: true,
paths: {
'rx': 'examples/src/web_workers/todo/rx.js'
}
defaultJSExtensions: true
});
System.import("examples/src/web_workers/todo/background_index")

View File

@ -1,5 +1,8 @@
{
"dependencies": {
"@reactivex/rxjs": {
"version": "0.0.0-prealpha.3"
},
"angular": {
"version": "1.3.5"
},

5
npm-shrinkwrap.json generated
View File

@ -2,6 +2,11 @@
"name": "angular",
"version": "2.0.0-alpha.37",
"dependencies": {
"@reactivex/rxjs": {
"version": "0.0.0-prealpha.3",
"from": "@reactivex/rxjs@0.0.0-prealpha.3",
"resolved": "https://registry.npmjs.org/@reactivex/rxjs/-/rxjs-0.0.0-prealpha.3.tgz"
},
"angular": {
"version": "1.3.5",
"from": "https://registry.npmjs.org/angular/-/angular-1.3.5.tgz",

View File

@ -28,8 +28,8 @@
"test": "gulp test.all.js && gulp test.all.dart"
},
"dependencies": {
"@reactivex/rxjs": "0.0.0-prealpha.3",
"reflect-metadata": "0.1.1",
"rx": "2.5.1",
"zone.js": "0.5.4"
},
"devDependencies": {

View File

@ -15,7 +15,7 @@ System.config({
'angular2/*': 'dist/js/dev/es5/angular2/*.js',
'angular2_material/*': 'dist/js/dev/es5/angular2_material/*.js',
'rtts_assert/*': 'dist/js/dev/es5/rtts_assert/*.js',
'rx': 'node_modules/rx/dist/rx.js'
'@reactivex/rxjs/*': 'node_modules/@reactivex/rxjs/*.js'
}
});

View File

@ -5,14 +5,9 @@
<script src="Reflect.js" type="text/javascript"></script>
<script type="text/javascript">
var filename = '@@FILENAME_NO_EXT';
var parent = filename.split('/');
parent = parent.splice(0, parent.length-1).join('/');
System.config({
baseURL: '/',
defaultJSExtensions: true,
paths: {
'rx': parent + '/rx.js'
}
defaultJSExtensions: true
});
System.import(filename).then(function(m) { m.main(); }, console.error.bind(console));
</script>

View File

@ -6,14 +6,9 @@
<script src="Reflect.js" type="text/javascript"></script>
<script type="text/javascript">
var filename = '@@FILENAME_NO_EXT';
var parent = filename.split('/');
parent = parent.splice(0, parent.length-1).join('/');
System.config({
baseURL: '/',
defaultJSExtensions: true,
paths: {
'rx': parent + '/rx.js'
}
defaultJSExtensions: true
});
System.import(filename).then(function(m) { m.main(); }, console.error.bind(console));
</script>

View File

@ -7,14 +7,9 @@
<script src="Reflect.js" type="text/javascript"></script>
<script type="text/javascript">
var filename = '@@FILENAME_NO_EXT';
var parent = filename.split('/');
parent = parent.splice(0, parent.length-1).join('/');
System.config({
baseURL: '/',
defaultJSExtensions: true,
paths: {
'rx': parent + '/rx.js'
}
defaultJSExtensions: true
});
System.import(filename).then(function(m) { m.main(); }, console.error.bind(console));
</script>

View File

@ -84,6 +84,8 @@ module.exports = function makeBrowserTree(options, destinationPath) {
destDir: '/'
});
var rxJs = new Funnel('node_modules/@reactivex', {include: ['**/**'], destDir: '/@reactivex'});
var es5ModulesTree = new Funnel('modules', {
include: ['**/**'],
exclude: ['**/*.cjs', 'angular1_router/**', 'benchmarks/e2e_test/**'],
@ -139,7 +141,6 @@ module.exports = function makeBrowserTree(options, destinationPath) {
'node_modules/zone.js/dist/zone-microtask.js',
'node_modules/zone.js/dist/long-stack-trace-zone.js',
'node_modules/systemjs/dist/system.src.js',
'node_modules/rx/dist/rx.js',
'node_modules/base64-js/lib/b64.js',
'node_modules/reflect-metadata/Reflect.js',
'node_modules/es6-shim/es6-shim.js'
@ -208,8 +209,8 @@ module.exports = function makeBrowserTree(options, destinationPath) {
htmlTree = mergeTrees([htmlTree, scripts, polymer, react]);
es5Tree = mergeTrees([es5Tree, htmlTree, assetsTree]);
es6Tree = mergeTrees([es6Tree, htmlTree, assetsTree]);
es5Tree = mergeTrees([es5Tree, htmlTree, assetsTree, rxJs]);
es6Tree = mergeTrees([es6Tree, htmlTree, assetsTree, rxJs]);
var mergedTree = mergeTrees([stew.mv(es6Tree, '/es6'), stew.mv(es5Tree, '/es5')]);