forked from Reactive-Extensions/RxJS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsink.js
More file actions
44 lines (34 loc) · 727 Bytes
/
Copy pathsink.js
File metadata and controls
44 lines (34 loc) · 727 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';
var noop = require('./noop');
var NoOpObserver = {
next: noop,
error: noop,
complete: noop
};
function Forwarder(fwd) {
this._fwd = fwd;
}
Forwarder.prototype.next = function (x) {
this._fwd._o.next(x);
};
Forwarder.prototype.error = function (e) {
this._fwd._o.error(e);
};
Forwarder.prototype.complete = function () {
this._fwd._o.complete();
this._fwd.dispose();
};
function Sink(o, cancel) {
this._o = o;
this._cancel = cancel;
}
Sink.prototype.dispose = function () {
this._o = NoOpObserver;
var cancel = this._cancel;
this._cancel = null;
cancel && cancel.dispose();
};
Sink.prototype.getForwarder = function () {
return new Forwarder(this);
};
module.exports = Sink;