X Tutup
Skip to content

Commit 43f42d9

Browse files
committed
feat(facade): do not reexport Observable from angular2/core
BREAKING CHANGE Before import {Observable} from 'angular2/core' After import {Observable} from 'rxjs/Observable';
1 parent a885f37 commit 43f42d9

File tree

10 files changed

+12
-85
lines changed

10 files changed

+12
-85
lines changed

modules/angular2/examples/core/pipes/ts/async_pipe/async_pipe_example.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import {Component, provide, Observable} from 'angular2/core';
1+
import {Component, provide} from 'angular2/core';
22
import {bootstrap} from 'angular2/bootstrap';
3+
import {Observable} from 'rxjs/Observable';
34

45
// #docregion AsyncPipe
56
@Component({

modules/angular2/examples/facade/ts/async/observable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// #docregion Observable
2-
import {Observable} from 'angular2/core';
2+
import {Observable} from 'rxjs/Observable';
33
var obs = new Observable<number>(obs => {
44
var i = 0;
55
setInterval(_ => { obs.next(++i); }, 1000);

modules/angular2/examples/facade/ts/async/observable_patched.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// #docregion Observable
2-
import {Observable} from 'angular2/core';
2+
import {Observable} from 'rxjs/Observable';
33
import 'rxjs/add/operator/map';
44

55
var obs = new Observable(obs => {

modules/angular2/examples/facade/ts/async/observable_pure.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// #docregion Observable
2-
import {Observable} from 'angular2/core';
2+
import {Observable} from 'rxjs/Observable';
33
import {map} from 'rxjs/operator/map';
44

55
var obs = new Observable(obs => {

modules/angular2/src/facade/async.ts

Lines changed: 3 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import {global, isPresent, noop} from 'angular2/src/facade/lang';
44
import {Promise} from 'angular2/src/facade/promise';
55
export {PromiseWrapper, Promise, PromiseCompleter} from 'angular2/src/facade/promise';
66

7+
import {Observable} from 'rxjs/Observable';
78
import {Subject} from 'rxjs/Subject';
8-
import {Observable as RxObservable} from 'rxjs/Observable';
99
import {Subscription} from 'rxjs/Subscription';
1010
import {Operator} from 'rxjs/Operator';
1111

1212
import {PromiseObservable} from 'rxjs/observable/fromPromise';
1313
import {toPromise} from 'rxjs/operator/toPromise';
1414

15+
export {Observable} from 'rxjs/Observable';
1516
export {Subject} from 'rxjs/Subject';
1617

1718
export namespace NodeJS {
@@ -160,74 +161,4 @@ export class EventEmitter<T> extends Subject<T> {
160161

161162
return super.subscribe(schedulerFn, errorFn, completeFn);
162163
}
163-
}
164-
165-
/**
166-
* Allows publishing and subscribing to series of async values.
167-
*
168-
* The `Observable` class is an alias to the `Observable` returned from
169-
* {@link https://github.com/reactivex/rxjs}. `Observables` are a means of delivering
170-
* any number of values over any period of time. `Observables` can be thought of as a
171-
* mixture of `Promise` and `Array`. `Observables` are like `Arrays` in that they can have
172-
* chained combinators -- like `map`, `reduce`, and `filter` -- attached in order to
173-
* perform projections and transformations of data. And they are like `Promises`
174-
* in that they can asynchronously deliver values. But unlike a `Promise`, an
175-
* `Observable` can emit many values over time, and decides if/when it is completed.
176-
*
177-
* `Observable` is also being considered for inclusion in the
178-
* [ECMAScript spec](https://github.com/zenparsing/es-observable).
179-
*
180-
* ## Example
181-
*
182-
* A simple example of using an `Observable` is a timer `Observable`, which will
183-
* notify an `Observer` each time an interval has completed.
184-
*
185-
* {@example facade/ts/async/observable.ts region='Observable'}
186-
*
187-
* The `Observable` in Angular currently doesn't provide any combinators by default.
188-
* So it's necessary to explicitly import any combinators that an application requires.
189-
* There are two ways to import RxJS combinators: pure and patched. The "pure" approach
190-
* involves importing a combinator as a function every place that an application needs it,
191-
* then calling the function with the source observable as the context of the function.
192-
*
193-
* ## Example
194-
*
195-
* {@example facade/ts/async/observable_pure.ts region='Observable'}
196-
*
197-
* The "patched" approach to using combinators is to import a special module for
198-
* each combinator, which will automatically cause the combinator to be patched
199-
* to the `Observable` prototype, which will make it available to use anywhere in
200-
* an application after the combinator has been imported once.
201-
*
202-
* ## Example
203-
*
204-
* (Notice the extra "add" in the path to import `map`)
205-
*
206-
* {@example facade/ts/async/observable_patched.ts region='Observable'}
207-
*
208-
* Notice that the sequence of operations is now able to be expressed "left-to-right"
209-
* because `map` is on the `Observable` prototype. For a simple example like this one,
210-
* the left-to-right expression may seem insignificant. However, when several operators
211-
* are used in combination, the "callback tree" grows several levels deep, and becomes
212-
* difficult to read. For this reason, the "patched" approach is the recommended approach
213-
* to add new operators to `Observable`.
214-
*
215-
* For applications that are less sensitive about payload size, the set of core operators
216-
* can be patched onto the `Observable` prototype with a single import, by importing the
217-
* `rxjs` module.
218-
*
219-
* {@example facade/ts/async/observable_all.ts region='Observable'}
220-
*
221-
* Full documentation on RxJS `Observable` and available combinators can be found
222-
* in the RxJS [Observable docs](http://reactivex.io/RxJS/class/es6/Observable.js~Observable.html).
223-
*
224-
*/
225-
// todo(robwormald): ts2dart should handle this properly
226-
export class Observable<T> extends RxObservable<T> {
227-
lift<T, R>(operator: Operator<T, R>): Observable<T> {
228-
const observable = new Observable();
229-
observable.source = this;
230-
observable.operator = operator;
231-
return observable;
232-
}
233-
}
164+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Public API for Facade
22
export {ConcreteType, Type} from './lang';
3-
export {Observable, EventEmitter} from './async';
3+
export {EventEmitter} from './async';
44
export {WrappedException} from './exceptions';
55
export {ExceptionHandler} from './exception_handler';

modules/angular2/src/http/backends/jsonp_backend.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {Injectable} from 'angular2/core';
77
import {BrowserJsonp} from './browser_jsonp';
88
import {makeTypeError} from 'angular2/src/facade/exceptions';
99
import {StringWrapper, isPresent} from 'angular2/src/facade/lang';
10-
import {Observable} from 'angular2/core';
10+
import {Observable} from 'rxjs/Observable';
1111

1212
const JSONP_ERR_NO_CALLBACK = 'JSONP injected script did not invoke callback.';
1313
const JSONP_ERR_WRONG_METHOD = 'JSONP requests must use GET request method.';

modules/angular2/src/http/backends/xhr_backend.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {ResponseOptions, BaseResponseOptions} from '../base_response_options';
77
import {Injectable} from 'angular2/core';
88
import {BrowserXhr} from './browser_xhr';
99
import {isPresent} from 'angular2/src/facade/lang';
10-
import {Observable} from 'angular2/core';
10+
import {Observable} from 'rxjs/Observable';
1111
import {isSuccess, getResponseURL} from '../http_utils';
1212
/**
1313
* Creates connections using `XMLHttpRequest`. Given a fully-qualified

modules/angular2/src/http/http.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {Request} from './static_request';
66
import {Response} from './static_response';
77
import {BaseRequestOptions, RequestOptions} from './base_request_options';
88
import {RequestMethod} from './enums';
9-
import {Observable} from 'angular2/core';
9+
import {Observable} from 'rxjs/Observable';
1010

1111
function httpRequest(backend: ConnectionBackend, request: Request): Observable<Response> {
1212
return backend.createConnection(request).response;

modules/angular2/test/public_api_spec.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,11 +1010,6 @@ var NG_CORE = [
10101010
RxJS API - may need to maintain as RxJS evolves
10111011
*/
10121012
'EventEmitter.emit():js',
1013-
'Observable:js',
1014-
'Observable#create():js',
1015-
'Observable.forEach():js',
1016-
'Observable.lift():js',
1017-
'Observable.subscribe():js',
10181013
'OutputMetadata',
10191014
'OutputMetadata.bindingPropertyName',
10201015
'enableDevMode():js',

0 commit comments

Comments
 (0)
X Tutup