Skip to content

Commit

Permalink
feat(Rx.Symbol.rxSubscriber): add rxSubscriber symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
benlesh committed Dec 8, 2015
1 parent feaaff0 commit d4f1670
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
13 changes: 13 additions & 0 deletions spec/symbol/rxSubscriber-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var Rx = require('../../dist/cjs/Rx');
var RxKitchenSink = require('../../dist/cjs/Rx.KitchenSink');
var Symbol = require('../../dist/cjs/util/SymbolShim').SymbolShim;

describe('rxSubscriber symbol', function () {
it('should exist on Rx', function () {
expect(Rx.Symbol.rxSubscriber).toBe(Symbol.for('rxSubscriber'));
});

it('should exist on Rx.KitchenSink', function () {
expect(RxKitchenSink.Symbol.rxSubscriber).toBe(Symbol.for('rxSubscriber'));
});
});
8 changes: 7 additions & 1 deletion src/Rx.KitchenSink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,18 @@ import {ImmediateScheduler} from './scheduler/ImmediateScheduler';
import {TimeInterval} from './operator/extended/timeInterval';
import {TestScheduler} from './testing/TestScheduler';
import {VirtualTimeScheduler} from './scheduler/VirtualTimeScheduler';
import {rxSubscriber} from './symbol/rxSubscriber';
/* tslint:enable:no-unused-variable */

/* tslint:disable:no-var-keyword */
var Scheduler = {
nextTick,
immediate
};

var Symbol = {
rxSubscriber
};
/* tslint:enable:no-var-keyword */

export {
Expand All @@ -171,5 +176,6 @@ export {
ObjectUnsubscribedError,
TestScheduler,
VirtualTimeScheduler,
TimeInterval
TimeInterval,
Symbol
};
6 changes: 6 additions & 0 deletions src/Rx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,18 @@ import {immediate} from './scheduler/immediate';
import {nextTick} from './scheduler/nextTick';
import {NextTickScheduler} from './scheduler/NextTickScheduler';
import {ImmediateScheduler} from './scheduler/ImmediateScheduler';
import {rxSubscriber} from './symbol/rxSubscriber';
/* tslint:enable:no-unused-variable */

/* tslint:disable:no-var-keyword */
var Scheduler = {
nextTick,
immediate
};

var Symbol = {
rxSubscriber
};
/* tslint:enable:no-var-keyword */

export {
Expand All @@ -137,6 +142,7 @@ export {
Observable,
Subscriber,
Subscription,
Symbol,
AsyncSubject,
ReplaySubject,
BehaviorSubject,
Expand Down
9 changes: 9 additions & 0 deletions src/symbol/rxSubscriber.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {SymbolShim} from '../util/SymbolShim';

/**
* rxSubscriber symbol is a symbol for retreiving an "Rx safe" Observer from an object
* "Rx safety" can be defined as an object that has all of the traits of an Rx Subscriber,
* including the ability to add and remove subscriptions to the subscription chain and
* guarantees involving event triggering (can't "next" after unsubscription, etc).
*/
export const rxSubscriber = SymbolShim.for('rxSubscriber');

0 comments on commit d4f1670

Please sign in to comment.