forked from Reactive-Extensions/RxJS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobserverbase.js
More file actions
44 lines (34 loc) · 857 Bytes
/
Copy pathobserverbase.js
File metadata and controls
44 lines (34 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
'use strict';
function ObserverBase() {
this._stopped = false;
}
ObserverBase.prototype.next = function (x) {
!this._stopped && this._next(x);
};
ObserverBase.prototype._next = function (x) { };
ObserverBase.prototype.error = function (e) {
if (!this._stopped) {
this._stopped = true;
this._error(e);
}
};
ObserverBase.prototype._error = function (e) { };
ObserverBase.prototype.complete = function () {
if (!this._stopped) {
this._stopped = true;
this._complete();
}
};
ObserverBase.prototype._complete = function () { };
ObserverBase.prototype.dispose = ObserverBase.prototype.unsubscribe = function () {
this._stopped = true;
};
ObserverBase.prototype.fail = function (e) {
if (!this._stopped) {
this._stopped = true;
this._error(e);
return true;
}
return false;
};
module.exports = ObserverBase;