Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compat): deprecate Observable.if/throw #3527

Merged
merged 2 commits into from
Apr 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dependency-cruiser.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"severity": "error",
"comment": "Error in case we have circular dependencies",
"from": {
"path": "^src"
"path": "^dist/esm5"
},
"to": {
"circular": true
Expand Down
3 changes: 1 addition & 2 deletions compat/add/observable/if.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Observable, iif } from 'rxjs';

//tslint:disable-next-line:no-any TypeScript doesn't like `if`
(Observable as any).if = iif;
Observable.if = iif;
2 changes: 1 addition & 1 deletion compat/add/observable/throw.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Observable, throwError as staticThrowError } from 'rxjs';

(Observable as any).throw = staticThrowError;
Observable.throw = staticThrowError;
Observable.throwError = staticThrowError;

declare module 'rxjs/internal/Observable' {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"test_browser": "npm-run-all build_spec_browser && opn spec/support/mocha-browser-runner.html",
"test": "mocha --require ts-node/register --opts spec-build/support/coverage.opts \"spec-build/**/*-spec.ts\"",
"test:cover": "cross-env TS_NODE_FAST=true nyc npm test",
"test:circular": "dependency-cruise --validate .dependency-cruiser.json -x \"^node_modules\" src",
"test:circular": "dependency-cruise --validate .dependency-cruiser.json -x \"^node_modules\" dist/esm5",
"test:systemjs": "node integration/systemjs/systemjs-compatibility-spec.js",
"tests2png": "mkdirp tmp/docs/img && cross-env TS_NODE_FAST=true mocha --compilers ts:ts-node/register --opts spec/support/tests2png.opts \"spec/**/*-spec.ts\"",
"watch": "watch \"echo triggering build && npm run build_spec && npm run test && echo build completed\" src -d -u -w=15",
Expand Down
15 changes: 12 additions & 3 deletions src/internal/Observable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Subscription } from './Subscription';
import { TeardownLogic } from './types';
import { toSubscriber } from './util/toSubscriber';
import { iif } from './observable/iif';
import { throwError } from './observable/throwError';
import { observable as Symbol_observable } from '../internal/symbol/observable';
import { OperatorFunction, PartialObserver, Subscribable } from '../internal/types';
import { pipeFromArray } from './util/pipe';
Expand Down Expand Up @@ -252,10 +253,18 @@ export class Observable<T> implements Subscribable<T> {
return source && source.subscribe(subscriber);
}

// TODO(benlesh): determine if this is still necessary
// `if` and `throw` are special snow flakes, the compiler sees them as reserved words
/** @nocollapse */
// `if` and `throw` are special snow flakes, the compiler sees them as reserved words. Deprecated in
// favor of iif and throwError functions.
/**
* @nocollapse
* @deprecated In favor of iif creation function: import { iif } from 'rxjs';
*/
static if: typeof iif;
/**
* @nocollapse
* @deprecated In favor of throwError creation function: import { throwError } from 'rxjs';
*/
static throw: typeof throwError;

/**
* An interop point defined by the es7-observable spec https://github.com/zenparsing/es-observable
Expand Down