Skip to content

Commit

Permalink
Merge pull request #2376 from ReactiveX/master
Browse files Browse the repository at this point in the history
Bring `next` branch up to date
  • Loading branch information
jayphelps authored Feb 15, 2017
2 parents 30b1436 + 7839002 commit a102b3c
Show file tree
Hide file tree
Showing 200 changed files with 2,005 additions and 595 deletions.
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
perf
spec
.git
yarn.lock
yarn.lock
coverage
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cache:
env:
matrix:
- NODE_VER=4 FULL_VALIDATE=false
- NODE_VER=6 FULL_VALIDATE=true alias grunt=./node_modules/grunt-cli/bin/grunt
- NODE_VER=6 FULL_VALIDATE=true alias grunt=./node_modules/grunt-cli/bin/grunt danger=./node_modules/danger/distribution/danger
- NODE_VER=7 FULL_VALIDATE=false
matrix:
fast_finish: true
Expand All @@ -23,6 +23,7 @@ before_install:
- nvm install $NODE_VER
- npm install -g npm@4 && node -v && npm -v
- if [ "$FULL_VALIDATE" == "true" ]; then npm install [email protected] grunt-cli grunt-contrib-connect grunt-run; fi
- if [ "$FULL_VALIDATE" == "true" ] && [ -n "DANGER_GITHUB_API_TOKEN" ]; then npm install danger && danger; fi

install:
- npm install
Expand Down
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
<a name="5.1.1"></a>
## [5.1.1](https:/ReactiveX/RxJS/compare/5.1.0...v5.1.1) (2017-02-13)


### Bug Fixes

* **bindCallback:** input function context can now be properly set via output function ([#2319](https:/ReactiveX/RxJS/issues/2319)) ([cb91c76](https:/ReactiveX/RxJS/commit/cb91c76))
* **bindNodeCallback:** input function context can now be properly set via output function ([#2320](https:/ReactiveX/RxJS/issues/2320)) ([3ec315d](https:/ReactiveX/RxJS/commit/3ec315d))
* **Subscription:** fold ChildSubscription logic into Subscriber to prevent operators from leaking ChildSubscriptions. ([#2360](https:/ReactiveX/RxJS/issues/2360)) ([22e4c17](https:/ReactiveX/RxJS/commit/22e4c17)), closes [#2244](https:/ReactiveX/RxJS/issues/2244) [#2355](https:/ReactiveX/RxJS/issues/2355)



<a name="5.1.0"></a>
# [5.1.0](https:/ReactiveX/RxJS/compare/5.0.3...v5.1.0) (2017-02-01)


### Bug Fixes

* **catch:** update the catch operator to dispose inner subscriptions if the catch subscription is di ([#2271](https:/ReactiveX/RxJS/issues/2271)) ([8a1e089](https:/ReactiveX/RxJS/commit/8a1e089))
* **combineLatest:** Don't mutate array of observables passed to ([#2276](https:/ReactiveX/RxJS/issues/2276)) ([9b73c46](https:/ReactiveX/RxJS/commit/9b73c46))
* **ISubscription:** update type definition of ISubscription::closed ([#2249](https:/ReactiveX/RxJS/issues/2249)) ([0c304a2](https:/ReactiveX/RxJS/commit/0c304a2))
* **Observable:** Ensure the generic type of the Observer passed to Observable's initializer function is the same. ([51a0bc1](https:/ReactiveX/RxJS/commit/51a0bc1)), closes [#2166](https:/ReactiveX/RxJS/issues/2166)
* **Observable:** errors thrown during subscription are now properly sent down error channel ([#2313](https:/ReactiveX/RxJS/issues/2313)) ([d4a9aac](https:/ReactiveX/RxJS/commit/d4a9aac)), closes [#1833](https:/ReactiveX/RxJS/issues/1833)
* **reduce:** index will properly start at 1 if no seed is provided, to match native Array reduce behavior ([30a4ca4](https:/ReactiveX/RxJS/commit/30a4ca4)), closes [#2290](https:/ReactiveX/RxJS/issues/2290)
* **repeatWhen:** resulting observable will wait for the source to complete, even if a hot notifier completes first. ([#2209](https:/ReactiveX/RxJS/issues/2209)) ([c65a098](https:/ReactiveX/RxJS/commit/c65a098)), closes [#2054](https:/ReactiveX/RxJS/issues/2054)
* **Subject:** ensure subject properly throws ObjectUnsubscribedError when unsubscribed then resubscribed to ([#2318](https:/ReactiveX/RxJS/issues/2318)) ([41489eb](https:/ReactiveX/RxJS/commit/41489eb))
* **TestScheduler:** helper methods return proper types, `HotObservable` and `ColdObservable` instead of Observable ([#2305](https:/ReactiveX/RxJS/issues/2305)) ([758aae9](https:/ReactiveX/RxJS/commit/758aae9))
* **windowTime:** ensure windows created when only a timespan is passed are closed and cleaned up properly. ([#2278](https:/ReactiveX/RxJS/issues/2278)) ([d4533c4](https:/ReactiveX/RxJS/commit/d4533c4))


### Features

* **fromEventPattern:** support optional removeHandler ([86960c2](https:/ReactiveX/RxJS/commit/86960c2))
* **fromEventPattern:** support pass signal from addHandler to removeHandler ([01d0622](https:/ReactiveX/RxJS/commit/01d0622))



<a name="5.0.3"></a>
## [5.0.3](https:/ReactiveX/RxJS/compare/5.0.2...v5.0.3) (2017-01-05)

Expand Down
68 changes: 68 additions & 0 deletions dangerfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
var fs = require('fs');
var path = require('path');
var _ = require('lodash');
var validateMessage = require('validate-commit-msg');

//simple regex matcher to detect usage of helper function and its type signature
var hotMatch = /\bhot\(/gi;
var hotSignatureMatch = /\bdeclare const hot: typeof/gi;

var coldMatch = /\bcold\(/gi;
var coldSignatureMatch = /\bdeclare const cold: typeof/gi;

var errorCount = 0;

// Warn when PR size is large
var bigPRThreshold = 600;
if (danger.github.pr.additions + danger.github.pr.deletions > bigPRThreshold) {
warn(':exclamation: Big PR (' + ++errorCount + ')');
markdown('> (' + errorCount + ') : Pull Request size seems relatively large. If Pull Request contains multiple changes, split each into separate PR will helps faster, easier review.');
}

// Check test exclusion (.only) is included
var modifiedSpecFiles = danger.git.modified_files.filter(function (filePath) {
return filePath.match(/-spec.(js|jsx|ts|tsx)$/gi);
});

var testFilesIncludeExclusion = modifiedSpecFiles.reduce(function (acc, value) {
var content = fs.readFileSync(value).toString();
var invalid = _.includes(content, 'it.only') || _.includes(content, 'describe.only');
if (invalid) {
acc.push(path.basename(value));
}
return acc;
}, []);

if (testFilesIncludeExclusion.length > 0) {
fail('an \`only\` was left in tests (' + testFilesIncludeExclusion + ')');
}

// Check test cases missing type signature import for test marble helper functions
var testFilesMissingTypes = modifiedSpecFiles.reduce(function (acc, value) {
var content = fs.readFileSync(value).toString();

var hotFnMatchesWithoutTypes = content.match(hotMatch) && !content.match(hotSignatureMatch);
var coldFnMatchesWithoutTypes = content.match(coldMatch) && !content.match(coldSignatureMatch);

if (hotFnMatchesWithoutTypes || coldFnMatchesWithoutTypes) {
acc.push(path.basename(value));
}

return acc;
}, []);

if (testFilesMissingTypes.length > 0) {
fail('missing type definition import in tests (' + testFilesMissingTypes + ') (' + ++errorCount + ')');
markdown('> (' + errorCount + ') : It seems updated test cases uses test scheduler interface `hot`, `cold` but miss to import type signature for those.');
}

//validate commit message in PR if it conforms conventional change log, notify if it doesn't.
var messageConventionValid = danger.git.commits.reduce(function (acc, value) {
var valid = validateMessage(value.message);
return valid && acc;
}, true);

if (!messageConventionValid) {
fail('commit message does not follows conventional change log (' + ++errorCount + ')');
markdown('> (' + errorCount + ') : RxJS uses conventional change log to generate changelog automatically. It seems some of commit messages are not following those, please check [contributing guideline](https:/ReactiveX/rxjs/blob/master/CONTRIBUTING.md#commit-message-format) and update commit messages.');
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reactivex/rxjs",
"version": "5.0.3",
"version": "5.1.1",
"description": "Reactive Extensions for modern JavaScript",
"main": "index.js",
"config": {
Expand Down Expand Up @@ -189,7 +189,7 @@
"sinon-chai": "^2.8.0",
"source-map-support": "^0.4.0",
"tslib": "^1.5.0",
"tslint": "^4.2.0",
"tslint": "^4.4.2",
"typescript": "~2.0.6",
"typings": "^2.0.0",
"validate-commit-msg": "^2.3.1",
Expand Down
7 changes: 6 additions & 1 deletion spec/Observable-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ import {expect} from 'chai';
import * as sinon from 'sinon';
import * as Rx from '../dist/cjs/Rx';
import {TeardownLogic} from '../dist/cjs/Subscription';
import marbleTestingSignature = require('./helpers/marble-testing'); // tslint:disable-line:no-require-imports

declare const { asDiagram, rxTestScheduler };
declare const cold: typeof marbleTestingSignature.cold;
declare const expectObservable: typeof marbleTestingSignature.expectObservable;
declare const expectSubscriptions: typeof marbleTestingSignature.expectSubscriptions;

declare const {asDiagram, expectObservable, rxTestScheduler};
const Subscriber = Rx.Subscriber;
const Observable = Rx.Observable;

Expand Down
8 changes: 7 additions & 1 deletion spec/Subject-spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import {expect} from 'chai';
import * as Rx from '../dist/cjs/Rx';
import marbleTestingSignature = require('./helpers/marble-testing'); // tslint:disable-line:no-require-imports

declare const {hot, expectObservable};
declare const { time };
declare const hot: typeof marbleTestingSignature.hot;
declare const expectObservable: typeof marbleTestingSignature.expectObservable;

const Subject = Rx.Subject;
const Observable = Rx.Observable;
Expand Down Expand Up @@ -261,6 +264,9 @@ describe('Subject', () => {
expect(() => {
subject.subscribe(
function (x) { results3.push(x); },
function (err) {
expect(false).to.equal('should not throw error: ' + err.toString());
}
);
}).to.throw(Rx.ObjectUnsubscribedError);

Expand Down
3 changes: 1 addition & 2 deletions spec/helpers/test-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import {$$iterator} from '../../dist/cjs/symbol/iterator';
import $$symbolObservable from 'symbol-observable';

export function lowerCaseO<T>(...args): Rx.Observable<T> {
const values = [].slice.apply(arguments);

const o = {
subscribe: function (observer) {
values.forEach(function (v) {
args.forEach(function (v) {
observer.next(v);
});
observer.complete();
Expand Down
5 changes: 4 additions & 1 deletion spec/observables/SubscribeOnObservable-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import {expect} from 'chai';
import * as sinon from 'sinon';
import * as Rx from '../../dist/cjs/Rx';
import {SubscribeOnObservable} from '../../dist/cjs/observable/SubscribeOnObservable';
import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports

declare const {hot, expectObservable, expectSubscriptions};
declare const hot: typeof marbleTestingSignature.hot;
declare const expectObservable: typeof marbleTestingSignature.expectObservable;
declare const expectSubscriptions: typeof marbleTestingSignature.expectSubscriptions;
declare const rxTestScheduler: Rx.TestScheduler;

describe('SubscribeOnObservable', () => {
Expand Down
74 changes: 74 additions & 0 deletions spec/observables/bindCallback-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@ const Observable = Rx.Observable;
/** @test {bindCallback} */
describe('Observable.bindCallback', () => {
describe('when not scheduled', () => {
it('should emit undefined from a callback without arguments', () => {
function callback(cb) {
cb();
}
const boundCallback = Observable.bindCallback(callback);
const results = [];

boundCallback()
.subscribe((x: any) => {
results.push(typeof x);
}, null, () => {
results.push('done');
});

expect(results).to.deep.equal(['undefined', 'done']);
});

it('should emit one value from a callback', () => {
function callback(datum, cb) {
cb(datum);
Expand All @@ -25,6 +42,24 @@ describe('Observable.bindCallback', () => {
expect(results).to.deep.equal([42, 'done']);
});

it('should set callback function context to context of returned function', () => {
function callback(cb) {
cb(this.datum);
}

const boundCallback = Observable.bindCallback(callback);
const results = [];

boundCallback.apply({datum: 5})
.subscribe(
(x: number) => results.push(x),
null,
() => results.push('done')
);

expect(results).to.deep.equal([5, 'done']);
});

it('should emit one value chosen by a selector', () => {
function callback(datum, cb) {
cb(datum);
Expand Down Expand Up @@ -86,6 +121,25 @@ describe('Observable.bindCallback', () => {
});

describe('when scheduled', () => {
it('should emit undefined from a callback without arguments', () => {
function callback(cb) {
cb();
}
const boundCallback = Observable.bindCallback(callback, null, rxTestScheduler);
const results = [];

boundCallback()
.subscribe((x: any) => {
results.push(typeof x);
}, null, () => {
results.push('done');
});

rxTestScheduler.flush();

expect(results).to.deep.equal(['undefined', 'done']);
});

it('should emit one value from a callback', () => {
function callback(datum, cb) {
cb(datum);
Expand All @@ -105,6 +159,26 @@ describe('Observable.bindCallback', () => {
expect(results).to.deep.equal([42, 'done']);
});

it('should set callback function context to context of returned function', () => {
function callback(cb) {
cb(this.datum);
}

const boundCallback = Observable.bindCallback(callback, null, rxTestScheduler);
const results = [];

boundCallback.apply({datum: 5})
.subscribe(
(x: number) => results.push(x),
null,
() => results.push('done')
);

rxTestScheduler.flush();

expect(results).to.deep.equal([5, 'done']);
});

it('should error if callback throws', () => {
const expected = new Error('haha no callback for you');
function callback(datum, cb) {
Expand Down
Loading

0 comments on commit a102b3c

Please sign in to comment.