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

Commit 6b3993e

Browse files
Fixing set/clearTimeout Issue #986
1 parent 30c794b commit 6b3993e

32 files changed

+486
-563
lines changed

dist/rx.all.compat.js

Lines changed: 46 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,30 +1723,41 @@
17231723
};
17241724
}
17251725

1726-
function ClearDisposable(method, id) {
1726+
function ClearDisposable(id) {
17271727
this._id = id;
1728-
this._method = method;
17291728
this.isDisposed = false;
17301729
}
17311730

17321731
ClearDisposable.prototype.dispose = function () {
17331732
if (!this.isDisposed) {
17341733
this.isDisposed = true;
1735-
this._method.call(null, this._id);
1734+
clearMethod(this._id);
1735+
}
1736+
};
1737+
1738+
function LocalClearDisposable(id) {
1739+
this._id = id;
1740+
this.isDisposed = false;
1741+
}
1742+
1743+
LocalClearDisposable.prototype.dispose = function () {
1744+
if (!this.isDisposed) {
1745+
this.isDisposed = true;
1746+
localClearTimeout(this._id);
17361747
}
17371748
};
17381749

17391750
DefaultScheduler.prototype.schedule = function (state, action) {
17401751
var disposable = new SingleAssignmentDisposable(),
17411752
id = scheduleMethod(scheduleAction(disposable, action, this, state));
1742-
return new BinaryDisposable(disposable, new ClearDisposable(clearMethod, id));
1753+
return new BinaryDisposable(disposable, new ClearDisposable(id));
17431754
};
17441755

17451756
DefaultScheduler.prototype._scheduleFuture = function (state, dueTime, action) {
17461757
if (dueTime === 0) { return this.schedule(state, action); }
17471758
var disposable = new SingleAssignmentDisposable(),
17481759
id = localSetTimeout(scheduleAction(disposable, action, this, state), dueTime);
1749-
return new BinaryDisposable(disposable, new ClearDisposable(localClearTimeout, id));
1760+
return new BinaryDisposable(disposable, new LocalClearDisposable(id));
17501761
};
17511762

17521763
return DefaultScheduler;
@@ -3993,85 +4004,63 @@ var ObserveOnObservable = (function (__super__) {
39934004
__super__.call(this);
39944005
}
39954006

3996-
MergeAllObservable.prototype.subscribeCore = function (observer) {
4007+
MergeAllObservable.prototype.subscribeCore = function (o) {
39974008
var g = new CompositeDisposable(), m = new SingleAssignmentDisposable();
39984009
g.add(m);
3999-
m.setDisposable(this.source.subscribe(new MergeAllObserver(observer, g)));
4010+
m.setDisposable(this.source.subscribe(new MergeAllObserver(o, g)));
40004011
return g;
40014012
};
40024013

4014+
return MergeAllObservable;
4015+
}(ObservableBase));
4016+
4017+
var MergeAllObserver = (function (__super__) {
40034018
function MergeAllObserver(o, g) {
40044019
this.o = o;
40054020
this.g = g;
4006-
this.isStopped = false;
40074021
this.done = false;
4022+
__super__.call(this);
40084023
}
4009-
MergeAllObserver.prototype.onNext = function(innerSource) {
4010-
if(this.isStopped) { return; }
4024+
4025+
inherits(MergeAllObserver, __super__);
4026+
4027+
MergeAllObserver.prototype.next = function(innerSource) {
40114028
var sad = new SingleAssignmentDisposable();
40124029
this.g.add(sad);
4013-
40144030
isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
4015-
40164031
sad.setDisposable(innerSource.subscribe(new InnerObserver(this, sad)));
40174032
};
4018-
MergeAllObserver.prototype.onError = function (e) {
4019-
if(!this.isStopped) {
4020-
this.isStopped = true;
4021-
this.o.onError(e);
4022-
}
4023-
};
4024-
MergeAllObserver.prototype.onCompleted = function () {
4025-
if(!this.isStopped) {
4026-
this.isStopped = true;
4027-
this.done = true;
4028-
this.g.length === 1 && this.o.onCompleted();
4029-
}
4033+
4034+
MergeAllObserver.prototype.error = function (e) {
4035+
this.o.onError(e);
40304036
};
4031-
MergeAllObserver.prototype.dispose = function() { this.isStopped = true; };
4032-
MergeAllObserver.prototype.fail = function (e) {
4033-
if (!this.isStopped) {
4034-
this.isStopped = true;
4035-
this.o.onError(e);
4036-
return true;
4037-
}
40384037

4039-
return false;
4038+
MergeAllObserver.prototype.completed = function () {
4039+
this.done = true;
4040+
this.g.length === 1 && this.o.onCompleted();
40404041
};
40414042

40424043
function InnerObserver(parent, sad) {
40434044
this.parent = parent;
40444045
this.sad = sad;
4045-
this.isStopped = false;
4046+
__super__.call(this);
40464047
}
4047-
InnerObserver.prototype.onNext = function (x) { if (!this.isStopped) { this.parent.o.onNext(x); } };
4048-
InnerObserver.prototype.onError = function (e) {
4049-
if(!this.isStopped) {
4050-
this.isStopped = true;
4051-
this.parent.o.onError(e);
4052-
}
4048+
4049+
inherits(InnerObserver, __super__);
4050+
4051+
InnerObserver.prototype.next = function (x) {
4052+
this.parent.o.onNext(x);
40534053
};
4054-
InnerObserver.prototype.onCompleted = function () {
4055-
if(!this.isStopped) {
4056-
var parent = this.parent;
4057-
this.isStopped = true;
4058-
parent.g.remove(this.sad);
4059-
parent.done && parent.g.length === 1 && parent.o.onCompleted();
4060-
}
4054+
InnerObserver.prototype.error = function (e) {
4055+
this.parent.o.onError(e);
40614056
};
4062-
InnerObserver.prototype.dispose = function() { this.isStopped = true; };
4063-
InnerObserver.prototype.fail = function (e) {
4064-
if (!this.isStopped) {
4065-
this.isStopped = true;
4066-
this.parent.o.onError(e);
4067-
return true;
4068-
}
4069-
4070-
return false;
4057+
InnerObserver.prototype.completed = function () {
4058+
this.parent.g.remove(this.sad);
4059+
this.parent.done && this.parent.g.length === 1 && this.parent.o.onCompleted();
40714060
};
40724061

4073-
return MergeAllObservable;
4074-
}(ObservableBase));
4062+
return MergeAllObserver;
4063+
}(AbstractObserver));
40754064

40764065
/**
40774066
* Merges an observable sequence of observable sequences into an observable sequence.

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: 5 additions & 5 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: 46 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,30 +1375,41 @@
13751375
};
13761376
}
13771377

1378-
function ClearDisposable(method, id) {
1378+
function ClearDisposable(id) {
13791379
this._id = id;
1380-
this._method = method;
13811380
this.isDisposed = false;
13821381
}
13831382

13841383
ClearDisposable.prototype.dispose = function () {
13851384
if (!this.isDisposed) {
13861385
this.isDisposed = true;
1387-
this._method.call(null, this._id);
1386+
clearMethod(this._id);
1387+
}
1388+
};
1389+
1390+
function LocalClearDisposable(id) {
1391+
this._id = id;
1392+
this.isDisposed = false;
1393+
}
1394+
1395+
LocalClearDisposable.prototype.dispose = function () {
1396+
if (!this.isDisposed) {
1397+
this.isDisposed = true;
1398+
localClearTimeout(this._id);
13881399
}
13891400
};
13901401

13911402
DefaultScheduler.prototype.schedule = function (state, action) {
13921403
var disposable = new SingleAssignmentDisposable(),
13931404
id = scheduleMethod(scheduleAction(disposable, action, this, state));
1394-
return new BinaryDisposable(disposable, new ClearDisposable(clearMethod, id));
1405+
return new BinaryDisposable(disposable, new ClearDisposable(id));
13951406
};
13961407

13971408
DefaultScheduler.prototype._scheduleFuture = function (state, dueTime, action) {
13981409
if (dueTime === 0) { return this.schedule(state, action); }
13991410
var disposable = new SingleAssignmentDisposable(),
14001411
id = localSetTimeout(scheduleAction(disposable, action, this, state), dueTime);
1401-
return new BinaryDisposable(disposable, new ClearDisposable(localClearTimeout, id));
1412+
return new BinaryDisposable(disposable, new LocalClearDisposable(id));
14021413
};
14031414

14041415
return DefaultScheduler;
@@ -3691,85 +3702,63 @@ var ObserveOnObservable = (function (__super__) {
36913702
__super__.call(this);
36923703
}
36933704

3694-
MergeAllObservable.prototype.subscribeCore = function (observer) {
3705+
MergeAllObservable.prototype.subscribeCore = function (o) {
36953706
var g = new CompositeDisposable(), m = new SingleAssignmentDisposable();
36963707
g.add(m);
3697-
m.setDisposable(this.source.subscribe(new MergeAllObserver(observer, g)));
3708+
m.setDisposable(this.source.subscribe(new MergeAllObserver(o, g)));
36983709
return g;
36993710
};
37003711

3712+
return MergeAllObservable;
3713+
}(ObservableBase));
3714+
3715+
var MergeAllObserver = (function (__super__) {
37013716
function MergeAllObserver(o, g) {
37023717
this.o = o;
37033718
this.g = g;
3704-
this.isStopped = false;
37053719
this.done = false;
3720+
__super__.call(this);
37063721
}
3707-
MergeAllObserver.prototype.onNext = function(innerSource) {
3708-
if(this.isStopped) { return; }
3722+
3723+
inherits(MergeAllObserver, __super__);
3724+
3725+
MergeAllObserver.prototype.next = function(innerSource) {
37093726
var sad = new SingleAssignmentDisposable();
37103727
this.g.add(sad);
3711-
37123728
isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
3713-
37143729
sad.setDisposable(innerSource.subscribe(new InnerObserver(this, sad)));
37153730
};
3716-
MergeAllObserver.prototype.onError = function (e) {
3717-
if(!this.isStopped) {
3718-
this.isStopped = true;
3719-
this.o.onError(e);
3720-
}
3721-
};
3722-
MergeAllObserver.prototype.onCompleted = function () {
3723-
if(!this.isStopped) {
3724-
this.isStopped = true;
3725-
this.done = true;
3726-
this.g.length === 1 && this.o.onCompleted();
3727-
}
3731+
3732+
MergeAllObserver.prototype.error = function (e) {
3733+
this.o.onError(e);
37283734
};
3729-
MergeAllObserver.prototype.dispose = function() { this.isStopped = true; };
3730-
MergeAllObserver.prototype.fail = function (e) {
3731-
if (!this.isStopped) {
3732-
this.isStopped = true;
3733-
this.o.onError(e);
3734-
return true;
3735-
}
37363735

3737-
return false;
3736+
MergeAllObserver.prototype.completed = function () {
3737+
this.done = true;
3738+
this.g.length === 1 && this.o.onCompleted();
37383739
};
37393740

37403741
function InnerObserver(parent, sad) {
37413742
this.parent = parent;
37423743
this.sad = sad;
3743-
this.isStopped = false;
3744+
__super__.call(this);
37443745
}
3745-
InnerObserver.prototype.onNext = function (x) { if (!this.isStopped) { this.parent.o.onNext(x); } };
3746-
InnerObserver.prototype.onError = function (e) {
3747-
if(!this.isStopped) {
3748-
this.isStopped = true;
3749-
this.parent.o.onError(e);
3750-
}
3746+
3747+
inherits(InnerObserver, __super__);
3748+
3749+
InnerObserver.prototype.next = function (x) {
3750+
this.parent.o.onNext(x);
37513751
};
3752-
InnerObserver.prototype.onCompleted = function () {
3753-
if(!this.isStopped) {
3754-
var parent = this.parent;
3755-
this.isStopped = true;
3756-
parent.g.remove(this.sad);
3757-
parent.done && parent.g.length === 1 && parent.o.onCompleted();
3758-
}
3752+
InnerObserver.prototype.error = function (e) {
3753+
this.parent.o.onError(e);
37593754
};
3760-
InnerObserver.prototype.dispose = function() { this.isStopped = true; };
3761-
InnerObserver.prototype.fail = function (e) {
3762-
if (!this.isStopped) {
3763-
this.isStopped = true;
3764-
this.parent.o.onError(e);
3765-
return true;
3766-
}
3767-
3768-
return false;
3755+
InnerObserver.prototype.completed = function () {
3756+
this.parent.g.remove(this.sad);
3757+
this.parent.done && this.parent.g.length === 1 && this.parent.o.onCompleted();
37693758
};
37703759

3771-
return MergeAllObservable;
3772-
}(ObservableBase));
3760+
return MergeAllObserver;
3761+
}(AbstractObserver));
37733762

37743763
/**
37753764
* Merges an observable sequence of observable sequences into an observable sequence.

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 & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)