Skip to content

Commit

Permalink
fix(symbol/rxSubscriber): will be exported as rxSubscriber to better …
Browse files Browse the repository at this point in the history
…support Babel UMD and others

To migrate the code follow the example bellow:

Before:

import { $$rxSubscriber } from 'rxjs/symbol/rxSubscriber';

After:

import { rxSubscriber } from 'rxjs/symbol/rxSubscriber';
  • Loading branch information
DzmitryShylovich committed Mar 16, 2017
1 parent c86a40d commit 234442e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Rx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ import { AsapScheduler } from './scheduler/AsapScheduler';
import { AsyncScheduler } from './scheduler/AsyncScheduler';
import { QueueScheduler } from './scheduler/QueueScheduler';
import { AnimationFrameScheduler } from './scheduler/AnimationFrameScheduler';
import { $$rxSubscriber as rxSubscriber } from './symbol/rxSubscriber';
import { rxSubscriber } from './symbol/rxSubscriber';
import { iterator } from './symbol/iterator';
import { observable } from './symbol/observable';

Expand Down
4 changes: 2 additions & 2 deletions src/Subject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Subscriber } from './Subscriber';
import { ISubscription, Subscription, TeardownLogic } from './Subscription';
import { ObjectUnsubscribedError } from './util/ObjectUnsubscribedError';
import { SubjectSubscription } from './SubjectSubscription';
import { $$rxSubscriber } from './symbol/rxSubscriber';
import { rxSubscriber as rxSubscriberSymbol } from './symbol/rxSubscriber';

/**
* @class SubjectSubscriber<T>
Expand All @@ -21,7 +21,7 @@ export class SubjectSubscriber<T> extends Subscriber<T> {
*/
export class Subject<T> extends Observable<T> implements ISubscription {

[$$rxSubscriber]() {
[rxSubscriberSymbol]() {
return new SubjectSubscriber(this);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { isFunction } from './util/isFunction';
import { Observer, PartialObserver } from './Observer';
import { Subscription } from './Subscription';
import { empty as emptyObserver } from './Observer';
import { $$rxSubscriber } from './symbol/rxSubscriber';
import { rxSubscriber as rxSubscriberSymbol } from './symbol/rxSubscriber';

/**
* Implements the {@link Observer} interface and extends the
Expand All @@ -16,7 +16,7 @@ import { $$rxSubscriber } from './symbol/rxSubscriber';
*/
export class Subscriber<T> extends Subscription implements Observer<T> {

[$$rxSubscriber]() { return this; }
[rxSubscriberSymbol]() { return this; }

/**
* A static factory for a Subscriber, given a (potentially partial) definition
Expand Down
7 changes: 6 additions & 1 deletion src/symbol/rxSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@ import { root } from '../util/root';

const Symbol: any = root.Symbol;

export const $$rxSubscriber = (typeof Symbol === 'function' && typeof Symbol.for === 'function') ?
export const rxSubscriber = (typeof Symbol === 'function' && typeof Symbol.for === 'function') ?
Symbol.for('rxSubscriber') : '@@rxSubscriber';

/**
* @deprecated use rxSubscriber instead
*/
export const $$rxSubscriber = rxSubscriber;
6 changes: 3 additions & 3 deletions src/util/toSubscriber.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Subscriber } from '../Subscriber';
import { $$rxSubscriber } from '../symbol/rxSubscriber';
import { rxSubscriber as rxSubscriberSymbol } from '../symbol/rxSubscriber';
import { PartialObserver, empty as emptyObserver } from '../Observer';

export function toSubscriber<T>(
Expand All @@ -12,8 +12,8 @@ export function toSubscriber<T>(
return (<Subscriber<T>> nextOrObserver);
}

if (nextOrObserver[$$rxSubscriber]) {
return nextOrObserver[$$rxSubscriber]();
if (nextOrObserver[rxSubscriberSymbol]) {
return nextOrObserver[rxSubscriberSymbol]();
}
}

Expand Down

0 comments on commit 234442e

Please sign in to comment.