Skip to content
This repository was archived by the owner on Apr 20, 2018. It is now read-only.

Commit a103d0c

Browse files
Addressing Issue #658
1 parent 8977f7c commit a103d0c

34 files changed

Lines changed: 221 additions & 105 deletions

dist/rx.aggregates.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@
269269
//deprecate('contains', 'includes');
270270
observableProto.includes(searchElement, fromIndex);
271271
};
272+
272273
/**
273274
* Returns an observable sequence containing a value that represents how many elements in the specified observable sequence satisfy a condition if provided, else the count of items.
274275
* @example

dist/rx.aggregates.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.all.compat.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -971,10 +971,17 @@
971971
if (disposable.isDisposed) { throw new ObjectDisposedError(); }
972972
};
973973

974-
var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable = (function () {
975-
function BooleanDisposable () {
974+
var BooleanDisposable = (function () {
975+
var trueInstance = (function () {
976+
var d = new BooleanDisposable();
977+
d.isDisposed = true;
978+
return d;
979+
}());
980+
981+
function BooleanDisposable (isSingle) {
976982
this.isDisposed = false;
977983
this.current = null;
984+
this.isSingle = isSingle;
978985
}
979986

980987
var booleanDisposablePrototype = BooleanDisposable.prototype;
@@ -984,15 +991,15 @@
984991
* @return The underlying disposable.
985992
*/
986993
booleanDisposablePrototype.getDisposable = function () {
987-
return this.current;
994+
return this.current === trueInstance ? disposableEmpty : this.current;
988995
};
989996

990997
/**
991998
* Sets the underlying disposable.
992999
* @param {Disposable} value The new underlying disposable.
9931000
*/
9941001
booleanDisposablePrototype.setDisposable = function (value) {
995-
var shouldDispose = this.isDisposed;
1002+
var shouldDispose = this.current === trueInstance;
9961003
if (!shouldDispose) {
9971004
var old = this.current;
9981005
this.current = value;
@@ -1006,16 +1013,21 @@
10061013
*/
10071014
booleanDisposablePrototype.dispose = function () {
10081015
if (!this.isDisposed) {
1009-
this.isDisposed = true;
10101016
var old = this.current;
1011-
this.current = null;
1017+
this.current = trueInstance;
1018+
this.isDisposed = trueInstance.isDisposed;
10121019
}
10131020
old && old.dispose();
10141021
};
10151022

10161023
return BooleanDisposable;
10171024
}());
1018-
var SerialDisposable = Rx.SerialDisposable = SingleAssignmentDisposable;
1025+
var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable = function () {
1026+
return new BooleanDisposable(true);
1027+
};
1028+
var SerialDisposable = Rx.SerialDisposable = function () {
1029+
return new BooleanDisposable();
1030+
};
10191031

10201032
/**
10211033
* Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed.
@@ -5442,6 +5454,7 @@
54425454
//deprecate('contains', 'includes');
54435455
observableProto.includes(searchElement, fromIndex);
54445456
};
5457+
54455458
/**
54465459
* Returns an observable sequence containing a value that represents how many elements in the specified observable sequence satisfy a condition if provided, else the count of items.
54475460
* @example

dist/rx.all.compat.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.all.compat.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.all.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -780,10 +780,17 @@
780780
if (disposable.isDisposed) { throw new ObjectDisposedError(); }
781781
};
782782

783-
var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable = (function () {
784-
function BooleanDisposable () {
783+
var BooleanDisposable = (function () {
784+
var trueInstance = (function () {
785+
var d = new BooleanDisposable();
786+
d.isDisposed = true;
787+
return d;
788+
}());
789+
790+
function BooleanDisposable (isSingle) {
785791
this.isDisposed = false;
786792
this.current = null;
793+
this.isSingle = isSingle;
787794
}
788795

789796
var booleanDisposablePrototype = BooleanDisposable.prototype;
@@ -793,15 +800,15 @@
793800
* @return The underlying disposable.
794801
*/
795802
booleanDisposablePrototype.getDisposable = function () {
796-
return this.current;
803+
return this.current === trueInstance ? disposableEmpty : this.current;
797804
};
798805

799806
/**
800807
* Sets the underlying disposable.
801808
* @param {Disposable} value The new underlying disposable.
802809
*/
803810
booleanDisposablePrototype.setDisposable = function (value) {
804-
var shouldDispose = this.isDisposed;
811+
var shouldDispose = this.current === trueInstance;
805812
if (!shouldDispose) {
806813
var old = this.current;
807814
this.current = value;
@@ -815,16 +822,21 @@
815822
*/
816823
booleanDisposablePrototype.dispose = function () {
817824
if (!this.isDisposed) {
818-
this.isDisposed = true;
819825
var old = this.current;
820-
this.current = null;
826+
this.current = trueInstance;
827+
this.isDisposed = trueInstance.isDisposed;
821828
}
822829
old && old.dispose();
823830
};
824831

825832
return BooleanDisposable;
826833
}());
827-
var SerialDisposable = Rx.SerialDisposable = SingleAssignmentDisposable;
834+
var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable = function () {
835+
return new BooleanDisposable(true);
836+
};
837+
var SerialDisposable = Rx.SerialDisposable = function () {
838+
return new BooleanDisposable();
839+
};
828840

829841
/**
830842
* Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed.
@@ -5297,6 +5309,7 @@
52975309
//deprecate('contains', 'includes');
52985310
observableProto.includes(searchElement, fromIndex);
52995311
};
5312+
53005313
/**
53015314
* Returns an observable sequence containing a value that represents how many elements in the specified observable sequence satisfy a condition if provided, else the count of items.
53025315
* @example

dist/rx.all.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.all.min.js

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.compat.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -971,10 +971,17 @@
971971
if (disposable.isDisposed) { throw new ObjectDisposedError(); }
972972
};
973973

974-
var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable = (function () {
975-
function BooleanDisposable () {
974+
var BooleanDisposable = (function () {
975+
var trueInstance = (function () {
976+
var d = new BooleanDisposable();
977+
d.isDisposed = true;
978+
return d;
979+
}());
980+
981+
function BooleanDisposable (isSingle) {
976982
this.isDisposed = false;
977983
this.current = null;
984+
this.isSingle = isSingle;
978985
}
979986

980987
var booleanDisposablePrototype = BooleanDisposable.prototype;
@@ -984,15 +991,15 @@
984991
* @return The underlying disposable.
985992
*/
986993
booleanDisposablePrototype.getDisposable = function () {
987-
return this.current;
994+
return this.current === trueInstance ? disposableEmpty : this.current;
988995
};
989996

990997
/**
991998
* Sets the underlying disposable.
992999
* @param {Disposable} value The new underlying disposable.
9931000
*/
9941001
booleanDisposablePrototype.setDisposable = function (value) {
995-
var shouldDispose = this.isDisposed;
1002+
var shouldDispose = this.current === trueInstance;
9961003
if (!shouldDispose) {
9971004
var old = this.current;
9981005
this.current = value;
@@ -1006,16 +1013,21 @@
10061013
*/
10071014
booleanDisposablePrototype.dispose = function () {
10081015
if (!this.isDisposed) {
1009-
this.isDisposed = true;
10101016
var old = this.current;
1011-
this.current = null;
1017+
this.current = trueInstance;
1018+
this.isDisposed = trueInstance.isDisposed;
10121019
}
10131020
old && old.dispose();
10141021
};
10151022

10161023
return BooleanDisposable;
10171024
}());
1018-
var SerialDisposable = Rx.SerialDisposable = SingleAssignmentDisposable;
1025+
var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable = function () {
1026+
return new BooleanDisposable(true);
1027+
};
1028+
var SerialDisposable = Rx.SerialDisposable = function () {
1029+
return new BooleanDisposable();
1030+
};
10191031

10201032
/**
10211033
* Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed.

dist/rx.compat.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)