-
Notifications
You must be signed in to change notification settings - Fork 0
/
xstreamObservableConfig.js
49 lines (42 loc) · 1.26 KB
/
xstreamObservableConfig.js
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
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _symbolObservable = _interopRequireDefault(require("symbol-observable"));
var _xstream = _interopRequireDefault(require("xstream"));
var noop = function noop() {};
var config = {
fromESObservable: function fromESObservable(observable) {
return _xstream.default.create({
subscription: null,
start: function start(listener) {
this.subscription = observable.subscribe(listener);
},
stop: function stop() {
this.subscription.unsubscribe();
}
});
},
toESObservable: function toESObservable(stream) {
var _ref;
return _ref = {
subscribe: function subscribe(observer) {
var listener = {
next: observer.next || noop,
error: observer.error || noop,
complete: observer.complete || noop
};
stream.addListener(listener);
return {
unsubscribe: function unsubscribe() {
return stream.removeListener(listener);
}
};
}
}, _ref[_symbolObservable.default] = function () {
return this;
}, _ref;
}
};
var _default = config;
exports.default = _default;