Skip to content

Commit

Permalink
Merge branch 'master' into static-observable-merge-docs-update
Browse files Browse the repository at this point in the history
  • Loading branch information
jayphelps authored Oct 24, 2016
2 parents d89d6b1 + ece1b89 commit 65bfaea
Show file tree
Hide file tree
Showing 226 changed files with 954 additions and 1,361 deletions.
10 changes: 0 additions & 10 deletions .make-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ var cjsPkg = Object.assign({}, pkg, {
main: 'Rx.js',
typings: 'Rx.d.ts'
});
var es6Pkg = Object.assign({}, cjsPkg, {
name: 'rxjs-es',
main: 'Rx.js',
typings: 'Rx.d.ts'
});

fs.writeFileSync('dist/cjs/package.json', JSON.stringify(cjsPkg, null, 2));
fs.writeFileSync('dist/cjs/LICENSE.txt', fs.readFileSync('./LICENSE.txt').toString());
Expand All @@ -34,11 +29,6 @@ fs.writeFileSync('dist/cjs/bundles/Rx.js', fs.readFileSync('dist/global/Rx.js').
fs.writeFileSync('dist/cjs/bundles/Rx.min.js', fs.readFileSync('dist/global/Rx.min.js').toString());
fs.writeFileSync('dist/cjs/bundles/Rx.min.js.map', fs.readFileSync('dist/global/Rx.min.js.map').toString());

// ES6 Package
fs.writeFileSync('dist/es6/package.json', JSON.stringify(es6Pkg, null, 2));
fs.writeFileSync('dist/es6/LICENSE.txt', fs.readFileSync('./LICENSE.txt').toString());
fs.writeFileSync('dist/es6/README.md', fs.readFileSync('./README.md').toString());

// Add licenses to tops of bundles
addLicenseToFile('LICENSE.txt', 'dist/cjs/bundles/Rx.js');
addLicenseTextToFile(license, 'dist/cjs/bundles/Rx.min.js');
Expand Down
46 changes: 46 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
<a name="5.0.0-rc.1"></a>
# [5.0.0-rc.1](https://github.com/ReactiveX/RxJS/compare/5.0.0-beta.12...v5.0.0-rc.1) (2016-10-11)


### Bug Fixes

* **AjaxObservable:** Fix for [#1921](https://github.com/ReactiveX/RxJS/issues/1921) exposed AjaxObservable unsubscription error calling xhr.abort(). ([4d23f87](https://github.com/ReactiveX/RxJS/commit/4d23f87))
* **AnonymousSubject:** is now exposed on Rx namespace ([0a6f049](https://github.com/ReactiveX/RxJS/commit/0a6f049)), closes [#2002](https://github.com/ReactiveX/RxJS/issues/2002)
* **bufferTime:** no errors with take after bufferTime with maxBufferSize ([ecec640](https://github.com/ReactiveX/RxJS/commit/ecec640)), closes [#1944](https://github.com/ReactiveX/RxJS/issues/1944)
* **docs:** Fix esdoc for Observable.merge spread argument ([b794e9b](https://github.com/ReactiveX/RxJS/commit/b794e9b))
* **Observer:** fix Observable#subscribe() signature to suggest correct usable ([459d2a2](https://github.com/ReactiveX/RxJS/commit/459d2a2))
* **operator:** Fix take to complete when the source is re-entrant. ([86615cb](https://github.com/ReactiveX/RxJS/commit/86615cb))
* **root:** find global context (window/self/global) in a more safe way ([a098132](https://github.com/ReactiveX/RxJS/commit/a098132)), closes [#1930](https://github.com/ReactiveX/RxJS/issues/1930)
* **schedulers:** Queue, Asap, and AnimationFrame Schedulers should be Async if delay > 0 ([d5c682c](https://github.com/ReactiveX/RxJS/commit/d5c682c))
* **util/toSubscriber:** Supplies the Subscriber constructor with emptyObserver as destination if no ([8e7e4e3](https://github.com/ReactiveX/RxJS/commit/8e7e4e3))
* **WebSocketSubject:** ensure all internal state properly reset when socket is nulled out ([62d242e](https://github.com/ReactiveX/RxJS/commit/62d242e)), closes [#1863](https://github.com/ReactiveX/RxJS/issues/1863)


### Features

* **cache:** remove `cache` operator ([1b23ace](https://github.com/ReactiveX/RxJS/commit/1b23ace))
* **ES2015:** stop publishing `rxjs-es`, ES2015 output no longer included in `@reactivex/rxjs` package under `/dist/es6` ([6be9968](https://github.com/ReactiveX/RxJS/commit/6be9968)), closes [#1671](https://github.com/ReactiveX/RxJS/issues/1671)
* **filter:** Observable<T>.filter() can take type guard as the predicate function ([d62fbf0](https://github.com/ReactiveX/RxJS/commit/d62fbf0))
* **find:** Observable<T>.find() can take type guard as the predicate function ([b952718](https://github.com/ReactiveX/RxJS/commit/b952718))
* **first:** Observable<T>.first() can take type guard as the predicate function ([f99ca49](https://github.com/ReactiveX/RxJS/commit/f99ca49))
* **last:** Observable<T>.last() can take type guard as the predicate function ([76a8a57](https://github.com/ReactiveX/RxJS/commit/76a8a57))
* **operators:** Use lift in the operators that don't currently use lift. ([68af9ef](https://github.com/ReactiveX/RxJS/commit/68af9ef))
* **TypeScript:** update TypeScript to v2.0 ([3478b0b](https://github.com/ReactiveX/RxJS/commit/3478b0b))


### BREAKING CHANGES

* **cache:** The .cache() operator has been removed, pending further discussion ([1b23ace](https://github.com/ReactiveX/RxJS/commit/1b23ace))
* ES2015: `rxjs-es` is no longer being published
* ES2015: `@reactivex/rxjs` no longer has `/dist/es6` output

related #2016
related #1992
* package.json: TypeScript definitions are now for TS 2.0 and higher

Even if we use getter for class, they are marked with `readonly` properties
in d.ts.
* operators: Removes MulticastObservable subclass in favor of a MulticastOperator.



<a name="5.0.0-beta.12"></a>
# [5.0.0-beta.12](https://github.com/ReactiveX/RxJS/compare/5.0.0-beta.11...v5.0.0-beta.12) (2016-09-09)

Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[![Selenium Test Status](https://saucelabs.com/browser-matrix/rxjs5.svg)](https://saucelabs.com/u/rxjs5)

# RxJS 5 (beta)
# RxJS 5 (release candidate)

Reactive Extensions Library for JavaScript. This is a rewrite of [Reactive-Extensions/RxJS](https://github.com/Reactive-Extensions/RxJS) and is intended to supersede it once this is ready. This rewrite is meant to have better performance, better modularity, better debuggable call stacks, while staying mostly backwards compatible, with some breaking changes that reduce the API surface.

Expand All @@ -27,7 +27,7 @@ By contributing or commenting on issues in this repository, whether you've read
### ES6 via npm

```sh
npm install rxjs-es
npm install rxjs
```

To import the entire core set of functionality:
Expand Down Expand Up @@ -106,7 +106,7 @@ npm install @reactivex/rxjs
If you are using npm **version 2** before this library has achieved a stable version, you need to specify the library version explicitly:

```sh
npm install @reactivex/rxjs@5.0.0-beta.1
npm install @reactivex/rxjs@5.0.0-rc.1
```

### CDN
Expand Down Expand Up @@ -180,6 +180,9 @@ For Mac OS X with [Homebrew](http://brew.sh/):
- `brew install imagemagick`
- `brew install graphicsmagick`
- `brew install ghostscript`
- You may need to install the Ghostscript fonts manually:
- Download the tarball from the [gs-fonts project](https://sourceforge.net/projects/gs-fonts)
- `mkdir -p /usr/local/share/ghostscript && tar zxvf /path/to/ghostscript-fonts.tar.gz -C /usr/local/share/ghostscript`

For Debian Linux:

Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ rename('file.txt', 'else.txt').subscribe(() => console.log('Renamed!'));
## Creating observables
Externally produce new events.
```js
var myObservable = Rx.Subject.create();
var myObservable = new Rx.Subject();
myObservable.subscribe(value => console.log(value));
myObservable.next('foo');
```
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reactivex/rxjs",
"version": "5.0.0-beta.12",
"version": "5.0.0-rc.1",
"description": "Reactive Extensions for modern JavaScript",
"main": "index.js",
"config": {
Expand Down Expand Up @@ -51,7 +51,7 @@
},
"scripts": {
"info": "npm-scripts-info",
"build_all": "npm-run-all build_es6 build_cjs build_global generate_packages",
"build_all": "npm-run-all build_cjs build_global generate_packages",
"build_cjs": "npm-run-all clean_dist_cjs copy_src_cjs compile_dist_cjs",
"build_es6": "npm-run-all clean_dist_es6 copy_src_es6 compile_dist_es6",
"build_es6_for_docs": "npm-run-all clean_dist_es6 copy_src_es6 compile_dist_es6_for_docs",
Expand All @@ -70,10 +70,10 @@
"copy_src_cjs": "mkdirp ./dist/cjs/src && shx cp -r ./src/* ./dist/cjs/src",
"copy_src_es6": "mkdirp ./dist/es6/src && shx cp -r ./src/* ./dist/es6/src",
"commit": "git-cz",
"compile_dist_cjs": "tsc typings/globals/es6-shim/index.d.ts ./dist/cjs/src/Rx.ts ./dist/cjs/src/add/observable/of.ts -m commonjs --sourceMap --outDir ./dist/cjs --target ES5 -d --diagnostics --pretty --noImplicitAny --noImplicitReturns --suppressImplicitAnyIndexErrors --moduleResolution node",
"compile_dist_cjs": "tsc ./dist/cjs/src/Rx.ts ./dist/cjs/src/add/observable/of.ts -m commonjs --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/cjs --target ES5 -d --diagnostics --pretty --noImplicitAny --noImplicitReturns --suppressImplicitAnyIndexErrors --moduleResolution node",
"compile_dist_es6": "tsc ./dist/es6/src/Rx.ts ./dist/es6/src/add/observable/of.ts -m es2015 --sourceMap --outDir ./dist/es6 --target ES6 -d --diagnostics --pretty --noImplicitAny --noImplicitReturns --suppressImplicitAnyIndexErrors --moduleResolution node",
"compile_dist_es6_for_docs": "tsc ./dist/es6/src/Rx.ts ./dist/es6/src/add/observable/of.ts ./dist/es6/src/MiscJSDoc.ts -m es2015 --sourceMap --outDir ./dist/es6 --target ES6 -d --diagnostics --pretty --noImplicitAny --noImplicitReturns --suppressImplicitAnyIndexErrors --moduleResolution node",
"cover": "shx rm -rf dist/cjs && tsc typings/globals/es6-shim/index.d.ts src/Rx.ts src/add/observable/of.ts -m commonjs --outDir dist/cjs --sourceMap --target ES5 -d && nyc --reporter=lcov --reporter=html --exclude=spec/support/**/* --exclude=spec-js/**/* --exclude=node_modules mocha --opts spec/support/default.opts spec-js",
"cover": "shx rm -rf dist/cjs && tsc src/Rx.ts src/add/observable/of.ts -m commonjs --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --outDir dist/cjs --sourceMap --target ES5 -d && nyc --reporter=lcov --reporter=html --exclude=spec/support/**/* --exclude=spec-js/**/* --exclude=node_modules mocha --opts spec/support/default.opts spec-js",
"decision_tree_widget": "cd doc/decision-tree-widget && npm run build && cd ../..",
"doctoc": "doctoc CONTRIBUTING.md",
"generate_packages": "node .make-packages.js",
Expand Down Expand Up @@ -184,7 +184,7 @@
"sinon-chai": "^2.8.0",
"source-map-support": "^0.4.0",
"tslint": "^3.15.1",
"typescript": "^1.8.10",
"typescript": "^2.0.3",
"typings": "^1.3.3",
"validate-commit-msg": "^2.3.1",
"watch": "^0.18.0",
Expand Down
4 changes: 4 additions & 0 deletions spec/Subject-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,10 @@ describe('Subject', () => {
});

describe('AnonymousSubject', () => {
it('should be exposed', () => {
expect(Rx.AnonymousSubject).to.be.a('function');
});

it('should not eager', () => {
let subscribed = false;

Expand Down
63 changes: 63 additions & 0 deletions spec/observables/IteratorObservable-spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {expect} from 'chai';
import * as Rx from '../../dist/cjs/Rx';
import {queue} from '../../dist/cjs/scheduler/queue';
import {IteratorObservable} from '../../dist/cjs/observable/IteratorObservable';

declare const expectObservable;
Expand Down Expand Up @@ -46,6 +47,68 @@ describe('IteratorObservable', () => {
);
});

it('should finalize generators if the subscription ends', () => {
const iterator = {
finalized: false,
next() {
return { value: 'duck', done: false };
},
return() {
this.finalized = true;
}
};

const iterable = {
[Rx.Symbol.iterator]() {
return iterator;
}
};

const results = [];

IteratorObservable.create(iterable)
.take(3)
.subscribe(
x => results.push(x),
null,
() => results.push('GOOSE!')
);

expect(results).to.deep.equal(['duck', 'duck', 'duck', 'GOOSE!']);
expect(iterator.finalized).to.be.true;
});

it('should finalize generators if the subscription and it is scheduled', () => {
const iterator = {
finalized: false,
next() {
return { value: 'duck', done: false };
},
return() {
this.finalized = true;
}
};

const iterable = {
[Rx.Symbol.iterator]() {
return iterator;
}
};

const results = [];

IteratorObservable.create(iterable, queue)
.take(3)
.subscribe(
x => results.push(x),
null,
() => results.push('GOOSE!')
);

expect(results).to.deep.equal(['duck', 'duck', 'duck', 'GOOSE!']);
expect(iterator.finalized).to.be.true;
});

it('should emit members of an array iterator on a particular scheduler', () => {
const source = IteratorObservable.create(
[10, 20, 30, 40],
Expand Down
97 changes: 75 additions & 22 deletions spec/observables/dom/webSocket-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,81 @@ describe('Observable.webSocket', () => {
});

describe('multiplex', () => {
it('should be retryable', () => {
const results = [];
const subject = Observable.webSocket('ws://websocket');
const source = subject.multiplex(() => {
return { sub: 'foo'};
}, () => {
return { unsub: 'foo' };
}, function (value: any) {
return value.name === 'foo';
});

source
.retry(1)
.map((x: any) => x.value)
.take(2)
.subscribe((x: any) => {
results.push(x);
});

const socket = MockWebSocket.lastSocket;
socket.open();

expect(socket.lastMessageSent).to.deep.equal({ sub: 'foo' });
socket.triggerClose({ wasClean: false }); // Bad connection

const socket2 = MockWebSocket.lastSocket;
expect(socket2).not.to.equal(socket);

socket2.open();
expect(socket2.lastMessageSent).to.deep.equal({ sub: 'foo' });

socket2.triggerMessage(JSON.stringify({ name: 'foo', value: 'test' }));
socket2.triggerMessage(JSON.stringify({ name: 'foo', value: 'this' }));

expect(results).to.deep.equal(['test', 'this']);
});

it('should be repeatable', () => {
const results = [];
const subject = Observable.webSocket('ws://websocket');
const source = subject.multiplex(() => {
return { sub: 'foo'};
}, () => {
return { unsub: 'foo' };
}, function (value: any) {
return value.name === 'foo';
});

source
.repeat(2)
.map((x: any) => x.value)
.subscribe((x: any) => {
results.push(x);
});

const socket = MockWebSocket.lastSocket;
socket.open();

expect(socket.lastMessageSent).to.deep.equal({ sub: 'foo' }, 'first multiplexed sub');
socket.triggerMessage(JSON.stringify({ name: 'foo', value: 'test' }));
socket.triggerMessage(JSON.stringify({ name: 'foo', value: 'this' }));
socket.triggerClose({ wasClean: true });

const socket2 = MockWebSocket.lastSocket;
expect(socket2).not.to.equal(socket, 'a new socket was not created');

socket2.open();
expect(socket2.lastMessageSent).to.deep.equal({ sub: 'foo' }, 'second multiplexed sub');
socket2.triggerMessage(JSON.stringify({ name: 'foo', value: 'test' }));
socket2.triggerMessage(JSON.stringify({ name: 'foo', value: 'this' }));
socket2.triggerClose({ wasClean: true });

expect(results).to.deep.equal(['test', 'this', 'test', 'this'], 'results were not equal');
});

it('should multiplex over the websocket', () => {
const results = [];
const subject = Observable.webSocket('ws://websocket');
Expand Down Expand Up @@ -432,28 +507,6 @@ describe('Observable.webSocket', () => {
(<any>socket.close).restore();
});

it('should work in combination with retry (issue #1466)', () => {
const error = { wasClean: false};
const results = [];

const subject = Observable.webSocket(<any>{url: 'ws://mysocket'})
.multiplex(
() => results.push('sub'),
() => results.push('unsub'),
() => true)
.retry(1);

subject.subscribe(
() => results.push('next'),
(e) => results.push(e));

let socket = MockWebSocket.lastSocket;

socket.triggerClose(error);

expect(results).to.deep.equal(['sub', 'unsub', 'sub', error, 'unsub']);
});

it('should not close the socket until all subscriptions complete', () => {
const socketSubject = Rx.Observable.webSocket(<any>{url: 'ws://mysocket'});
const results = [];
Expand Down
19 changes: 19 additions & 0 deletions spec/operators/bufferTime-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,23 @@ describe('Observable.prototype.bufferTime', () => {
expectObservable(result).toBe(expected, values);
expectSubscriptions(e1.subscriptions).toBe(subs);
});

it('should not have errors when take follows and maxBufferSize is provided', () => {
const tick = 10;
const bufferTime = 50;
const expected = '-----a----b----c----d----(e|)';
const values = {
a: [0, 1, 2, 3],
b: [4, 5, 6, 7, 8],
c: [9, 10, 11, 12, 13],
d: [14, 15, 16, 17, 18],
e: [19, 20, 21, 22, 23]
};

const source = Rx.Observable.interval(tick, rxTestScheduler)
.bufferTime(bufferTime, null, 10, rxTestScheduler)
.take(5);

expectObservable(source).toBe(expected, values);
});
});
Loading

0 comments on commit 65bfaea

Please sign in to comment.