forked from kamilkisiela/apollo-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
38 lines (38 loc) · 1.2 KB
/
utils.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
import { observeOn } from 'rxjs/operator/observeOn';
import { queue } from 'rxjs/scheduler/queue';
import { Observable } from 'rxjs/Observable';
export function fromPromise(promiseFn) {
return new Observable(function (subscriber) {
promiseFn().then(function (result) {
if (!subscriber.closed) {
subscriber.next(result);
subscriber.complete();
}
}, function (error) {
if (!subscriber.closed) {
subscriber.error(error);
}
});
return function () { return subscriber.unsubscribe(); };
});
}
var ZoneScheduler = /** @class */ (function () {
function ZoneScheduler(zone) {
this.zone = zone;
}
ZoneScheduler.prototype.schedule = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return this.zone.run(function () {
return queue.schedule.apply(queue, args);
});
};
return ZoneScheduler;
}());
export { ZoneScheduler };
export function wrapWithZone(obs) {
return observeOn.call(obs, new ZoneScheduler(Zone.current));
}
//# sourceMappingURL=utils.js.map