Skip to content

Commit

Permalink
feat(never): no longer export never function
Browse files Browse the repository at this point in the history
BREAKING CHANGE: no longer exported. Use the `NEVER` constant instead.
  • Loading branch information
benlesh committed Mar 7, 2018
1 parent 1e4ca05 commit cae623c
Show file tree
Hide file tree
Showing 21 changed files with 307 additions and 303 deletions.
4 changes: 0 additions & 4 deletions spec/exports-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ describe('exports', () => {
expect(merge).to.equal(Rx.Observable.merge);
});

it('should have rxjs/observable/never', () => {
expect(never).to.equal(Rx.Observable.never);
});

it('should have rxjs/observable/of', () => {
expect(of).to.equal(Rx.Observable.of);
});
Expand Down
2 changes: 1 addition & 1 deletion spec/index-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe('index', () => {

it('should export constants', () => {
expect(index.EMPTY).to.exist;
expect(index.NEVER).to.exist;
});

it('should export static observable creator functions', () => {
Expand All @@ -60,7 +61,6 @@ describe('index', () => {
expect(index.iif).to.exist;
expect(index.interval).to.exist;
expect(index.merge).to.exist;
expect(index.never).to.exist;
expect(index.of).to.exist;
expect(index.onErrorResumeNext).to.exist;
expect(index.pairs).to.exist;
Expand Down
4 changes: 2 additions & 2 deletions spec/observables/fromEvent-spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { expectObservable } from '../helpers/marble-testing';
import { fromEvent, never, timer } from '../../src';
import { fromEvent, NEVER, timer } from '../../src';
import { TestScheduler } from '../../src/testing';

declare function asDiagram(arg: string): Function;
Expand All @@ -15,7 +15,7 @@ describe('fromEvent', () => {
timer(50, 20, rxTestScheduler)
.mapTo('ev')
.take(2)
.concat(never())
.concat(NEVER)
.subscribe(listener);
},
removeEventListener: () => void 0,
Expand Down
4 changes: 2 additions & 2 deletions spec/observables/fromEventPattern-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from 'chai';
import * as sinon from 'sinon';
import { expectObservable } from '../helpers/marble-testing';

import { fromEventPattern, noop, never, timer } from '../../src';
import { fromEventPattern, noop, NEVER, timer } from '../../src';
import { TestScheduler } from '../../src/testing';

declare function asDiagram(arg: string): Function;
Expand All @@ -16,7 +16,7 @@ describe('fromEventPattern', () => {
timer(50, 20, rxTestScheduler)
.mapTo('ev')
.take(2)
.concat(never())
.concat(NEVER)
.subscribe(h);
}
const e1 = fromEventPattern(addHandler);
Expand Down
4 changes: 2 additions & 2 deletions spec/observables/interval-spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import * as sinon from 'sinon';
import { expectObservable } from '../helpers/marble-testing';
import { asapScheduler, Observable, animationFrameScheduler, queueScheduler } from '../../src';
import { NEVER, asapScheduler, Observable, animationFrameScheduler, queueScheduler } from '../../src';
import { TestScheduler } from '../../src/testing';
import { interval } from '../../src/';

Expand All @@ -13,7 +13,7 @@ describe('interval', () => {
asDiagram('interval(1000)')('should create an observable emitting periodically', () => {
const e1 = interval(20, rxTestScheduler)
.take(6) // make it actually finite, so it can be rendered
.concat(Observable.never()); // but pretend it's infinite by not completing
.concat(NEVER); // but pretend it's infinite by not completing
const expected = '--a-b-c-d-e-f-';
const values = {
a: 0,
Expand Down
12 changes: 6 additions & 6 deletions spec/observables/never-spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { never } from '../../src/';
import { NEVER } from '../../src/';
import { expect } from 'chai';
import { expectObservable } from '../helpers/marble-testing';

declare const asDiagram: any;

/** @test {never} */
describe('never', () => {
asDiagram('never')('should create a cold observable that never emits', () => {
/** @test {NEVER} */
describe('NEVER', () => {
asDiagram('NEVER')('should create a cold observable that never emits', () => {
const expected = '-';
const e1 = never();
const e1 = NEVER;
expectObservable(e1).toBe(expected);
});

it('should return the same instance every time', () => {
expect(never()).to.equal(never());
expect(NEVER).to.equal(NEVER);
});
});
4 changes: 2 additions & 2 deletions spec/observables/timer-spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cold, expectObservable, time } from '../helpers/marble-testing';
import { timer, never, merge } from '../../src/';
import { timer, NEVER, merge } from '../../src/';
import { TestScheduler } from '../../src/testing';
import { mergeMap } from '../../src/operators';

Expand All @@ -11,7 +11,7 @@ describe('timer', () => {
asDiagram('timer(3000, 1000)')('should create an observable emitting periodically', () => {
const e1 = timer(60, 20, rxTestScheduler)
.take(4) // make it actually finite, so it can be rendered
.concat(never()); // but pretend it's infinite by not completing
.concat(NEVER); // but pretend it's infinite by not completing
const expected = '------a-b-c-d-';
const values = {
a: 0,
Expand Down
82 changes: 41 additions & 41 deletions spec/operators/buffer-spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import * as Rx from '../../src/Rx';
import { hot, expectObservable, expectSubscriptions } from '../helpers/marble-testing';
import { buffer, mergeMap, take } from '../../src/operators';
import { EMPTY, NEVER, throwError, of } from '../../src';

declare function asDiagram(arg: string): Function;

const Observable = Rx.Observable;

/** @test {buffer} */
describe('Observable.prototype.buffer', () => {
asDiagram('buffer')('should emit buffers that close and reopen', () => {
Expand All @@ -16,77 +15,77 @@ describe('Observable.prototype.buffer', () => {
y: ['d', 'e', 'f'],
z: ['g', 'h', 'i']
};
expectObservable(a.buffer(b)).toBe(expected, expectedValues);
expectObservable(a.pipe(buffer(b))).toBe(expected, expectedValues);
});

it('should work with empty and empty selector', () => {
const a = Observable.empty();
const b = Observable.empty();
const a = EMPTY;
const b = EMPTY;
const expected = '|';
expectObservable(a.buffer(b)).toBe(expected);
expectObservable(a.pipe(buffer(b))).toBe(expected);
});

it('should work with empty and non-empty selector', () => {
const a = Observable.empty();
const a = EMPTY;
const b = hot('-----a-----');
const expected = '|';
expectObservable(a.buffer(b)).toBe(expected);
expectObservable(a.pipe(buffer(b))).toBe(expected);
});

it('should work with non-empty and empty selector', () => {
const a = hot('--1--2--^--3--4--5---6----7--8--9---0---|');
const b = Observable.empty();
const b = EMPTY;
const expected = '|';
expectObservable(a.buffer(b)).toBe(expected);
expectObservable(a.pipe(buffer(b))).toBe(expected);
});

it('should work with never and never selector', () => {
const a = Observable.never();
const b = Observable.never();
const a = NEVER;
const b = NEVER;
const expected = '-';
expectObservable(a.buffer(b)).toBe(expected);
expectObservable(a.pipe(buffer(b))).toBe(expected);
});

it('should work with never and empty selector', () => {
const a = Observable.never();
const b = Observable.empty();
const a = NEVER;
const b = EMPTY;
const expected = '|';
expectObservable(a.buffer(b)).toBe(expected);
expectObservable(a.pipe(buffer(b))).toBe(expected);
});

it('should work with empty and never selector', () => {
const a = Observable.empty();
const b = Observable.never();
const a = EMPTY;
const b = NEVER;
const expected = '|';
expectObservable(a.buffer(b)).toBe(expected);
expectObservable(a.pipe(buffer(b))).toBe(expected);
});

it('should work with non-empty and throw selector', () => {
const a = hot('---^--a--');
const b = Observable.throw(new Error('too bad'));
const b = throwError(new Error('too bad'));
const expected = '#';
expectObservable(a.buffer(b)).toBe(expected, null, new Error('too bad'));
expectObservable(a.pipe(buffer(b))).toBe(expected, null, new Error('too bad'));
});

it('should work with throw and non-empty selector', () => {
const a = Observable.throw(new Error('too bad'));
const a = throwError(new Error('too bad'));
const b = hot('---^--a--');
const expected = '#';
expectObservable(a.buffer(b)).toBe(expected, null, new Error('too bad'));
expectObservable(a.pipe(buffer(b))).toBe(expected, null, new Error('too bad'));
});

it('should work with error', () => {
const a = hot('---^-------#', null, new Error('too bad'));
const b = hot('---^--------');
const expected = '--------#';
expectObservable(a.buffer(b)).toBe(expected, null, new Error('too bad'));
expectObservable(a.pipe(buffer(b))).toBe(expected, null, new Error('too bad'));
});

it('should work with error and non-empty selector', () => {
const a = hot('---^-------#', null, new Error('too bad'));
const b = hot('---^---a----');
const expected = '----a---#';
expectObservable(a.buffer(b)).toBe(expected, { a: [] }, new Error('too bad'));
expectObservable(a.pipe(buffer(b))).toBe(expected, { a: [] }, new Error('too bad'));
});

it('should work with selector', () => {
Expand All @@ -98,11 +97,11 @@ describe('Observable.prototype.buffer', () => {
a: ['3'],
b: ['4', '5'],
c: ['6'],
d: [],
d: [] as string[],
e: ['7', '8', '9'],
f: ['0']
};
expectObservable(a.buffer(b)).toBe(expected, expectedValues);
expectObservable(a.pipe(buffer(b))).toBe(expected, expectedValues);
});

it('should work with selector completed', () => {
Expand All @@ -115,9 +114,9 @@ describe('Observable.prototype.buffer', () => {
a: ['3'],
b: ['4', '5'],
c: ['6'],
d: []
d: [] as string[]
};
expectObservable(a.buffer(b)).toBe(expected, expectedValues);
expectObservable(a.pipe(buffer(b))).toBe(expected, expectedValues);
expectSubscriptions(a.subscriptions).toBe(subs);
});

Expand All @@ -131,7 +130,7 @@ describe('Observable.prototype.buffer', () => {
a: ['3'],
b: ['4', '5']
};
expectObservable(a.buffer(b), unsub).toBe(expected, expectedValues);
expectObservable(a.pipe(buffer(b)), unsub).toBe(expected, expectedValues);
expectSubscriptions(a.subscriptions).toBe(subs);
});

Expand All @@ -146,10 +145,11 @@ describe('Observable.prototype.buffer', () => {
b: ['4', '5']
};

const result = a
.mergeMap((x: any) => Observable.of(x))
.buffer(b)
.mergeMap((x: any) => Observable.of(x));
const result = a.pipe(
mergeMap((x: any) => of(x)),
buffer(b),
mergeMap((x: any) => of(x)),
);

expectObservable(result, unsub).toBe(expected, expectedValues);
expectSubscriptions(a.subscriptions).toBe(subs);
Expand All @@ -163,17 +163,17 @@ describe('Observable.prototype.buffer', () => {
const expected = '---a--b--#';
const expectedValues = {
a: [3],
b: []
b: [] as string[]
};
expectObservable(a.buffer(b)).toBe(expected, expectedValues, new Error('too bad'));
expectObservable(a.pipe(buffer(b))).toBe(expected, expectedValues, new Error('too bad'));
expectSubscriptions(a.subscriptions).toBe(subs);
});

it('should work with non-empty and empty selector error', () => {
const a = hot('--1--2--^--3--4--5---6----7--8--9---0---|');
const b = hot('--------^----------------#', null, new Error('too bad'));
const expected = '-----------------#';
expectObservable(a.buffer(b)).toBe(expected, null, new Error('too bad'));
expectObservable(a.pipe(buffer(b))).toBe(expected, null, new Error('too bad'));
});

it('should work with non-empty and selector error', () => {
Expand All @@ -188,7 +188,7 @@ describe('Observable.prototype.buffer', () => {
b: ['4', '5'],
c: ['6']
};
expectObservable(a.buffer(b)).toBe(expected, expectedValues, new Error('too bad'));
expectObservable(a.pipe(buffer(b))).toBe(expected, expectedValues, new Error('too bad'));
expectSubscriptions(a.subscriptions).toBe(subs);
});

Expand All @@ -204,7 +204,7 @@ describe('Observable.prototype.buffer', () => {
b: ['4', '5']
};

expectObservable(a.buffer(b), unsub).toBe(expected, expectedValues);
expectObservable(a.pipe(buffer(b)), unsub).toBe(expected, expectedValues);
expectSubscriptions(a.subscriptions).toBe(subs);
expectSubscriptions(b.subscriptions).toBe(bsubs);
});
Expand All @@ -218,7 +218,7 @@ describe('Observable.prototype.buffer', () => {
x: ['a', 'b', 'c'],
};

expectObservable(a.buffer(b).take(1)).toBe(expected, expectedValues);
expectObservable(a.pipe(buffer(b), take(1))).toBe(expected, expectedValues);
expectSubscriptions(b.subscriptions).toBe(bsubs);
});
});
2 changes: 1 addition & 1 deletion spec/operators/catch-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ describe('Observable.prototype.catch', () => {
expectSubscriptions(e2.subscriptions).toBe(e2subs);
});

it('should never terminate if you return Observable.never()', () => {
it('should never terminate if you return NEVER', () => {
const e1 = hot('--a--b--#');
const e1subs = '^ !';
const e2 = cold( '-');
Expand Down
3 changes: 2 additions & 1 deletion spec/operators/debounce-spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect } from 'chai';
import * as Rx from '../../src/Rx';
import { hot, cold, expectObservable, expectSubscriptions } from '../helpers/marble-testing';
import { NEVER } from '../../src/internal/observable/never';

declare const type;
declare function asDiagram(arg: string): Function;
Expand Down Expand Up @@ -316,7 +317,7 @@ describe('Observable.prototype.debounce', () => {
const e1subs = '^ !';
const expected = '------------------------------------(z|)';

function selectorFunction(x) { return Observable.never<number>(); }
function selectorFunction() { return NEVER; }

expectObservable(e1.debounce(selectorFunction)).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
Expand Down
Loading

0 comments on commit cae623c

Please sign in to comment.