-
Notifications
You must be signed in to change notification settings - Fork 0
/
flydObservableConfig.js
60 lines (48 loc) · 1.43 KB
/
flydObservableConfig.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
50
51
52
53
54
55
56
57
58
59
60
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _symbolObservable = _interopRequireDefault(require("symbol-observable"));
var _flyd = _interopRequireDefault(require("flyd"));
var noop = function noop() {};
var config = {
fromESObservable: function fromESObservable(observable) {
var stream = _flyd.default.stream();
var _observable$subscribe = observable.subscribe({
next: function next(value) {
return stream(value);
},
error: function error(_error) {
return stream({
error: _error
});
},
complete: function complete() {
return stream.end(true);
}
}),
unsubscribe = _observable$subscribe.unsubscribe;
_flyd.default.on(unsubscribe, stream.end);
return stream;
},
toESObservable: function toESObservable(stream) {
var _ref;
return _ref = {
subscribe: function subscribe(observer) {
var sub = _flyd.default.on(observer.next || noop, stream);
_flyd.default.on(function (_) {
return observer.complete();
}, sub.end);
return {
unsubscribe: function unsubscribe() {
return sub.end(true);
}
};
}
}, _ref[_symbolObservable.default] = function () {
return this;
}, _ref;
}
};
var _default = config;
exports.default = _default;