blob: 4235b96605b25f40e7ca5c074cbee18b5202946b (
plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
(function() {
var CompositeDisposable;
module.exports = CompositeDisposable = (function() {
CompositeDisposable.prototype.disposed = false;
/*
Section: Construction and Destruction
*/
function CompositeDisposable() {
var disposable, _i, _len;
this.disposables = [];
for (_i = 0, _len = arguments.length; _i < _len; _i++) {
disposable = arguments[_i];
this.add(disposable);
}
}
CompositeDisposable.prototype.dispose = function() {
var disposable, _i, _len, _ref;
if (!this.disposed) {
this.disposed = true;
_ref = this.disposables;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
disposable = _ref[_i];
disposable.dispose();
}
return this.clear();
}
};
/*
Section: Managing Disposables
*/
CompositeDisposable.prototype.add = function(disposable) {
if (!this.disposed) {
return this.disposables.push(disposable);
}
};
CompositeDisposable.prototype.remove = function(disposable) {
var index;
index = this.disposables.indexOf(disposable);
if (index !== -1) {
return this.disposables.splice(index, 1);
}
};
CompositeDisposable.prototype.clear = function() {
return this.disposables.length = 0;
};
return CompositeDisposable;
})();
}).call(this);
|